简体   繁体   中英

ModuleNotFoundError: No module named 'cv2' on Jupyter notebook

so, i was trying to import cv2 to my jupyter notebook.

but it said

ModuleNotFoundError
Traceback (most recent call last) in ----> 1 import cv2

ModuleNotFoundError: No module named 'cv2'

i already installed it using the command: pip install opencv-python I'm on MacOS Catalina, please help me.

Do you have more than one python version installed? If so, make sure you are using the python interpreter you think you use for your notebook. Run

!pip freeze

in your notebook to check if opencv-python is really listed as an installed package. if not install it for that version or

Change Interpreter in Jupyter notebook

I faced similar problem when installing opencv using conda and troubleshooted this by adding kernel manually as described in this page https://www.programmersought.com/article/97466914065/

The following are adaptations from the above-mentioned page:

  1. First install ipykernel

    conda install ipykernel

  2. Add kernel manually

    python -m ipykernel install --name stm32 --display-name "stm32h7"

Now, install cv2 again and inside the Jupyter Notebook, activate the stm32h7 kernel by clicking on Kernel --> Change Kernel --> stm32h7 . Now, try to import cv2 again.

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