Skip to content

Commit

Permalink
Improved check_requirements() offline-handling (ultralytics#3466)
Browse files Browse the repository at this point in the history
Improve robustness of `check_requirements()` function to offline environments (do not attempt pip installs when offline).
  • Loading branch information
glenn-jocher committed Jun 4, 2021
1 parent ea73700 commit 1e18b06
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion utils/general.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,10 +163,11 @@ def check_requirements(requirements='requirements.txt', exclude=()):
try:
pkg.require(r)
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...")
try:
assert check_online(), f"'pip install {r}' skipped (offline)"
print(check_output(f"pip install '{r}'", shell=True).decode())
n += 1
except Exception as e:
print(f'{prefix} {e}')

Expand Down

0 comments on commit 1e18b06

Please sign in to comment.