简体   繁体   中英

Error when importing cv2 on anaconda prompt but it is working on jupyter notebook

I am importing libraries that I installed using pip install to Jupyter Notebook using the anaconda distribution, which is working. Next, I am trying to import the same libraries in the anaconda command prompt and running it. I am getting this error message:

ModuleNotFoundError: No module named 'cv2'

try these things:

  1. First check if you are able to see your library by this command: $ pip list or conda list

  2. if not available install this module: $ pip install opencv-python or conda install opencv-python

  3. But before that, try to check numpy module is available or not. If numpy is not available, then install this first. $ pip install numpy

  4. If all of them exist then, Uninstall opencv-python and numpy first and upgrade your pip using the below command. $ pip install --upgrade pip

Two options to install cv2 with the latest conda & python3:

  1. Open the Anaconda Prompt and switch to your environment:
    $ conda activate myenv
    Then install opencv from the menpo channel:
    $ conda install -c menpo opencv

  2. Open the Anaconda Prompt with admin permission and make sure you're in the base environment: $ conda activate base
    Then install opencv from the menpo channel:
    $ conda install -c menpo opencv

Reconnect your notebook to the kernel to import cv2.

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