简体   繁体   中英

Unable to import cv2 using Anaconda 4.5 Python 3.6.6

I am currently new to python. I have installing python 3.6 using Anaconda version 4.5. After installing few packages below I am unable to import cv2:

pip install numpy scipy matplotlib scikit-learn jupyter
pip install opencv-contrib-python

错误无法导入 CV2

I have tried installing various version of cv2 but none works.

First of all, when only conda and python are installed, activate the conda environment then use following command to install

conda install -c anaconda opencv 

OR

conda install -c conda-forge opencv

if you have R and Rstudio or multiple environments, there are chances of conflict of different versions of python.

Then you first have to activate the conda environment and run the following command:

pip install opencv-python

that will take few minutes to install the opencv library.

First, try again using the conda command:

conda install -c conda-forge opencv

A common mistake I personally did that caused this kind of problem is when you install the package in an environment but run jupyter from another one (like from the base environment).

I would suggest you:

1- use conda list in your environment to check the packages are correctly installed.

2- make sure the environment where you installed the packages is activate before running the command: jupyter notebook

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM