From 7ea8ef9f241d4ea2d2e66f2bb662d4bceb42cbc6 Mon Sep 17 00:00:00 2001 From: Glenn Jocher Date: Sun, 23 May 2021 18:00:23 +0200 Subject: [PATCH] Improved check_requirements() robustness (#3298) Add try: except clause on missing requirements install to catch install failures. Prompted by Ultralytics YOLOv5 API failure on Cython. (cherry picked from commit 9f3a388cea66ca71b9bbe057929eed8fbc920a7e) --- utils/general.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/utils/general.py b/utils/general.py index fc59ad1e5dd1..1244ae2505a8 100644 --- a/utils/general.py +++ b/utils/general.py @@ -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