Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 8037

Python • Re: Unable to import cv2 on OpenCV installation

$
0
0
It follows along fine until I get to the last step, the import. Then it returns error “ModuleNotFoundError: No module named ‘cv2’”


Another transcript of a working example. Perhaps you could share the actual output of your own attempt?

Code:

david@rp58book101064fnvme:~/Support $ mkdir DevGuydavid@rp58book101064fnvme:~/Support $ cd DevGuy/david@rp58book101064fnvme:~/Support/DevGuy $ python -m venv envdavid@rp58book101064fnvme:~/Support/DevGuy $ source env/bin/activate(env) david@rp58book101064fnvme:~/Support/DevGuy $ pip install opencv-pythonLooking in indexes: https://pypi.org/simple, https://www.piwheels.org/simpleCollecting opencv-python[ ... ]Installing collected packages: numpy, opencv-pythonSuccessfully installed numpy-2.2.2 opencv-python-4.11.0.86(env) david@rp58book101064fnvme:~/Support/DevGuy $ pythonPython 3.11.2 (main, Sep 14 2024, 03:00:30) [GCC 12.2.0] on linuxType "help", "copyright", "credits" or "license" for more information.>>> import cv2>>> img = cv2.imread('Raspberry_Pi_OS.png')>>> print(img.size,img.shape)4800 (40, 40, 3)>>> >>> 
(The stuff after import.cv2 is just to prove that the installed/imported module actually works. Not needed for troubleshooting the initial setup.)

Statistics: Posted by B.Goode — Sat Feb 01, 2025 8:11 am



Viewing all articles
Browse latest Browse all 8037

Trending Articles