Unverified 提交 317f2ccc authored 作者: Glenn Jocher's avatar Glenn Jocher 提交者: GitHub

Improved `check_requirements()` offline-handling (#3466)

Improve robustness of `check_requirements()` function to offline environments (do not attempt pip installs when offline).
上级 563ea947
...@@ -163,10 +163,11 @@ def check_requirements(requirements='requirements.txt', exclude=()): ...@@ -163,10 +163,11 @@ def check_requirements(requirements='requirements.txt', exclude=()):
try: try:
pkg.require(r) pkg.require(r)
except Exception as e: # DistributionNotFound or VersionConflict if requirements not met except Exception as e: # DistributionNotFound or VersionConflict if requirements not met
n += 1
print(f"{prefix} {r} not found and is required by YOLOv5, attempting auto-update...") print(f"{prefix} {r} not found and is required by YOLOv5, attempting auto-update...")
try: try:
assert check_online(), f"'pip install {r}' skipped (offline)"
print(check_output(f"pip install '{r}'", shell=True).decode()) print(check_output(f"pip install '{r}'", shell=True).decode())
n += 1
except Exception as e: except Exception as e:
print(f'{prefix} {e}') print(f'{prefix} {e}')
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论