-
-
Notifications
You must be signed in to change notification settings - Fork 16.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Requirements: opencv-python>=4.1.2 not found and is required by YOLOv5 Jetson Nano #3073
Comments
👋 Hello @HorusMaster, thank you for your interest in 🚀 YOLOv5! Please visit our ⭐️ Tutorials to get started, where you can find quickstart guides for simple tasks like Custom Data Training all the way to advanced concepts like Hyperparameter Evolution. If this is a 🐛 Bug Report, please provide screenshots and minimum viable code to reproduce your issue, otherwise we can not help you. If this is a custom training ❓ Question, please provide as much information as possible, including dataset images, training logs, screenshots, and a public link to online W&B logging if available. For business inquiries or professional support requests please visit https://www.ultralytics.com or email Glenn Jocher at glenn.jocher@ultralytics.com. RequirementsPython 3.8 or later with all requirements.txt dependencies installed, including $ pip install -r requirements.txt EnvironmentsYOLOv5 may be run in any of the following up-to-date verified environments (with all dependencies including CUDA/CUDNN, Python and PyTorch preinstalled):
StatusIf this badge is green, all YOLOv5 GitHub Actions Continuous Integration (CI) tests are currently passing. CI tests verify correct operation of YOLOv5 training (train.py), testing (test.py), inference (detect.py) and export (export.py) on MacOS, Windows, and Ubuntu every 24 hours and on every commit. |
@HorusMaster thanks for raising this bug report! I think your seeing a similar issue to others. We have a check_requirements() function that relies on the
|
@HorusMaster can you compare the output of the three commands below and report back if your opencv-installation is recognized in each one? python command 1 import pkg_resources
installed_packages = pkg_resources.working_set
installed_packages_list = sorted(["%s==%s" % (i.key, i.version)
for i in installed_packages])
print(installed_packages_list) python command 2 from importlib import metadata
metadata.metadata('opencv-python')['Version'] bash command pip freeze |
@glenn-jocher please consider not mentioning unrelated users when you quote people. I got a notification because of your comment mentioning me, but I have nothing to do with this issue or even project. |
@HorusMaster good news 😃! Your original issue may now be fixed ✅ in PR #3298. This PR increases robustness to failures in
Thank you for spotting this issue and informing us of the problem. Please let us know if this update resolves the issue for you, and feel free to inform us of any other issues you discover or feature requests that come to mind. Happy trainings with YOLOv5 🚀! |
🐛 Bug
I build OpenCV on jetson nano from scratch and also created a symlink to the site packages.
ln -s /usr/lib/python3.6/dist-packages/cv2/python-3.6/cv2.cpython-36m-aarch64-linux-gnu.so /home/jetson/.local/lib/python3.6/site-packages/
I reproduced the following example (python3 example.py):
import cv2
import torch
from PIL import Image
model = torch.hub.load('ultralytics/yolov5', 'yolov5s')
for f in ['zidane.jpg', 'bus.jpg']: # download 2 images
print(f'Downloading {f}...')
torch.hub.download_url_to_file('https://github.com/ultralytics/yolov5/releases/download/v1.0/' + f, f)
img1 = Image.open('zidane.jpg') # PIL image
img2 = cv2.imread('bus.jpg')[:, :, ::-1] # OpenCV image (BGR to RGB)
imgs = [img1, img2] # batch of images
results = model(imgs, size=640) # includes NMS
results.print()
results.save() # or .show()
Output
jetson@jetson-desktop:~$ python3 example.py
Using cache found in /home/jetson/.cache/torch/hub/ultralytics_yolov5_master
requirements: opencv-python>=4.1.2 not found and is required by YOLOv5, attempting auto-update...
/bin/sh: 1: pip: not found
Traceback (most recent call last):
File "/home/jetson/.cache/torch/hub/ultralytics_yolov5_master/utils/general.py", line 126, in check_requirements
pkg.require(r)
File "/home/jetson/.local/lib/python3.6/site-packages/pkg_resources/init.py", line 886, in require
needed = self.resolve(parse_requirements(requirements))
File "/home/jetson/.local/lib/python3.6/site-packages/pkg_resources/init.py", line 772, in resolve
raise DistributionNotFound(req, requirers)
pkg_resources.DistributionNotFound: The 'opencv-python>=4.1.2' distribution was not found and is required by the application
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "example.py", line 6, in
model = torch.hub.load('ultralytics/yolov5', 'yolov5s')
File "/home/jetson/.local/lib/python3.6/site-packages/torch/hub.py", line 339, in load
model = _load_local(repo_or_dir, model, *args, **kwargs)
File "/home/jetson/.local/lib/python3.6/site-packages/torch/hub.py", line 365, in _load_local
hub_module = import_module(MODULE_HUBCONF, hubconf_path)
File "/home/jetson/.local/lib/python3.6/site-packages/torch/hub.py", line 74, in import_module
spec.loader.exec_module(module)
File "", line 678, in exec_module
File "", line 219, in _call_with_frames_removed
File "/home/jetson/.cache/torch/hub/ultralytics_yolov5_master/hubconf.py", line 18, in
check_requirements(Path(file).parent / 'requirements.txt', exclude=('tensorboard', 'pycocotools', 'thop'))
File "/home/jetson/.cache/torch/hub/ultralytics_yolov5_master/utils/general.py", line 130, in check_requirements
print(subprocess.check_output(f"pip install '{r}'", shell=True).decode())
File "/usr/lib/python3.6/subprocess.py", line 356, in check_output
**kwargs).stdout
File "/usr/lib/python3.6/subprocess.py", line 438, in run
output=stdout, stderr=stderr)
subprocess.CalledProcessError: Command 'pip install 'opencv-python>=4.1.2'' returned non-zero exit status 127.
Environment
Additional context
The system recognizes the opencv Version correctly:
jetson@jetson-desktop:~$ python3 -c "import cv2; print(cv2.version)"
4.5.1
The text was updated successfully, but these errors were encountered: