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
python3.6 -m pip install opencv-python
will install cv2 in python3.6 branch
When I was facing this issue I used to install OpenCV in pycharm installed package panel where we can find under the settings tab. Search "OpenCV-python" and install it in the installed package panel of right interpreter.
you must install opencv-python
pip/pip3 install opencv-python
if you try import opencv-python
, receive error.
Fix this error, use the import cv2
Try this. I am using Jupyter notebook (OS: Ubuntu 16.04 LTS on Google Cloud Platform + on Windows). Executed following command in the Jupyter notebook to install opencv:
!pip install opencv-contrib-python #working on both Windows and Ubuntu
After successful installation you will get following message:
Successfully installed opencv-contrib-python-4.1.0.25
Now restart the kernel and try to import opencv as:
import cv2
The same command can be used to installed opencv on Windows as well.
SOLUTION 2: try following commands to install opencv: For Ubuntu: Run following command from terminal:
sudo apt-get install libsm6 libxrender1 libfontconfig1
Restart Jupyter notebook kernel and execute following command:
!pip install opencv-contrib-python
NOTE: You can run all the above commands from the terminal as well without using '!'.
In jetso nano this work for me.
$ git clone https://github.com/JetsonHacksNano/buildOpenCV
$ cd buildOpenCV
I had the same problem. Here are the steps for Windows 10 users.
Open CMD: win+r
then type cmd
. Now,
pip install virtualenv
virtualenv testopencv
cd testopencv
.\Scripts\activate
pip install opencv-contrib-python --upgrade
Python
then import cv2
hit enter then type print(cv2.__version__)
to check if its installedNow, open a new cmd, win + r then type cmd
, repeat step 6. If it gives you an error.
Go inside the testopencv
folder, inside lib
. Copy everything, go to your python directory, inside lib
folder paste it and skip that are already present.
Again open a new cmd, repeat Step 6
.
Hope it helps.