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.

(cherry picked from commit 9f3a388)
  • Loading branch information
glenn-jocher authored and Lechtr committed May 24, 2021
1 parent 55a8b27 commit 7ea8ef9
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 @@ -140,7 +140,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 7ea8ef9

Please sign in to comment.