0

I installed openCV in my environment using '''conda-forge'''.

It works in my terminal

❯ python
Python 3.8.2 (default, Mar 26 2020, 10:43:30) 
[Clang 4.0.1 (tags/RELEASE_401/final)] :: Anaconda, Inc. on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import cv2

But it doesn't work on my Jupyter Notebook

import cv2
---------------------------------------------------------------------------
ModuleNotFoundError                       Traceback (most recent call last)
<ipython-input-1-c8ec22b3e787> in <module>
----> 1 import cv2

ModuleNotFoundError: No module named 'cv2'

I am using Python 3.8.2. It shows on my conda list and the environment package list of anaconda. Please help.

The images show both environments having the openCV package

  • I would guess you didn't install it in the environment used by jupyter. In Jupyter you can select different kernels. Check which kernel you're using on the kernel tab in notebook or the button in the upper right in Lab. – Trenton McKinney Jun 20 '20 at 21:24
  • It only has a Python 3 Kernel. I get the same error even when i run jupyter notebook from my environment with opencv installed in it. – Bhaskar Ghosh Jun 20 '20 at 22:11
  • Does this answer your question? [cv2 import error on Jupyter notebook](https://stackoverflow.com/questions/38109270/cv2-import-error-on-jupyter-notebook) & [Import OpenCV on jupyter notebook](https://stackoverflow.com/questions/52832991/import-opencv-on-jupyter-notebook) & [Unable to import opencv in Jupyter notebook but able to import in command line on Anaconda](https://stackoverflow.com/questions/41248940/unable-to-import-opencv-in-jupyter-notebook-but-able-to-import-in-command-line-o) – Trenton McKinney Jun 20 '20 at 22:20
  • 1
    Thank you @Trenton. source activate Vision python -m ipykernel install --user --name Vision --display-name "Python (Vision)" Then selecting the Python (vision) from Jupyter Notebook solved this! – Bhaskar Ghosh Jun 21 '20 at 03:10

1 Answers1

1

Thank you @Trenton.

python -m ipykernel install --user --name Vision --display-name "Python (Vision)" 

Then selecting the Python (vision) from Jupyter Notebook solved this!