I\'ve been trying to install both OpenCV and cv2 from both Pycharm and from the terminal as suggested using:
pip install --user opencv
pip install --user cv2
This the correct command that you need to install opencv
pip install opencv-python
if you get any error when you are trying to install the "opencv-python" package in pycharm, make sure that you have added your python path to 'System Variables' section of Environment variables in Windows. And also check whether you have configured a valid interpreter for your project
In win, download the py based latest numpy and Opencv from Unofficial Windows Binaries for Python Extension Packages and pip install its source in cmd. Later copy site-package folder from main py lib to venv lib.
this will help you
pip3 install opencv-python
this is the snippet of successful installation
How about try some different mirrors? If you are in China, I highly recommend you try:
sudo pip install --index https://pypi.mirrors.ustc.edu.cn/simple/ opencv-contrib-python
If not, just replace the url address to some other mirrors you like! Good luck.
On Windows : !pip install opencv-python
I ran into the same problem. One issue might be OpenCV is created for Python 2.7, not 3 (not all python 2.7 libraries will work in python 3 or greater). I also don't believe you can download OpenCV directly through PyCharm's package installer. I have found luck following the instructions: OpenCV Python. Specifically:
import cv2
, and assuming no errors print cv2.__version__
Alternatively, I have had luck using this package opencv-python, which you can straightforwardly install using pip with pip install opencv-python
Good luck!