Skip to content

Commit

Permalink
Improved check_requirements() robustness (ultralytics#3298)
Browse files Browse the repository at this point in the history
Add try: except clause on missing requirements install to catch install failures. Prompted by Ultralytics YOLOv5 API failure on Cython.
  • Loading branch information
glenn-jocher authored May 23, 2021
1 parent f34cfd7 commit 3728452
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion utils/general.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,10 @@ def check_requirements(requirements='requirements.txt', exclude=()):
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(subprocess.check_output(f"pip install '{r}'", shell=True).decode())
try:
print(subprocess.check_output(f"pip install '{r}'", shell=True).decode())
except Exception as e:
print(f'{prefix} {e}')

if n: # if packages updated
source = file.resolve() if 'file' in locals() else requirements
Expand Down

0 comments on commit 3728452

Please sign in to comment.