No module named cv2 mac os

cv2 import issue in jupyter notebook, but works in python cli inside conda environment #13

Comments

ptgamr commented Apr 30, 2018

When I ran first cell on Notebook 1, I got the following error:

But when I enter python cli within the anaconda env, import cv2 works just fine.

The text was updated successfully, but these errors were encountered:

ptgamr commented Apr 30, 2018

This is my pip install btw,

sunsided commented Apr 30, 2018

It could be that it’s not picking up your environment. If that is true, try installing nb_conda within your environment and then start Jupyter from there.

This should allow you to select the correct kernel in the notebook (e.g. via the Kernel menu).

cezannec commented Apr 30, 2018

Yes, I suspect it’s the environment. Another solution, that shouldn’t require an install, is that you can also go to the top of your notebook and click Kernel > Change Kernel > cv-nd . I bet you are not the only one experiencing this problem and so I will add some clarifications to the readme instructions 🙂 thank you!

Читайте также:  Все обновления для windows server 2012 r2

ptgamr commented Apr 30, 2018

@cezannec I don’t see cv-nd option when changing the kernel. Am I missing something?

cezannec commented May 1, 2018

Hmm, I see, did you follow the instructions for environment creation in the readme of this project? They guide you in creating and starting an environment named cv-nd . If you still don’t see that option after following the instructions. I suggest that you follow sunsided’s comment and in your environment install nb_conda which will allow you to see a dropdown list of all your environments.

ptgamr commented May 1, 2018

@cezannec thanks. I think I figured it out. I did conda install jupyter after source activate cv-nd , now it’s picking up the correct env.

Redwa commented Jul 30, 2018

Thanks @ptgamr for asking and @sunsided for answering . It is working after I followed your instructions (conda install nb_conda)

akshayjaryal603 commented Sep 4, 2018

Thanks @sunsided (conda install nb_conda) this command help me a lot. I puzzled for two days for resolving this error then I found this error. @cezannec ma’am please include this command in the readme file.

radu941208 commented Oct 27, 2018

This helped me so much; i spent hours figuring out system variables and path and finally, i got the right Issue Page.
Thanks

zabir-nabil commented Feb 9, 2019

Add virtual environment to jupyter notebook.
After activating conda virtual environment ( conda activate virtual_env ), install ipykernel ( pip install ipykernel ), finally add the virtual_env to jupyter notebook with ( python -m ipykernel install —user —name=virtual_env ). Now, inside jupyter notebook select the virtual_env instead of default python installation.

Читайте также:  Widi для windows 10 как подключить телевизор

shivani792 commented Nov 9, 2019

i follow the step of @sunsided and @cezannec but still faced same problem.module cv2 is not found.plz help me to figure out this.`ModuleNotFoundError Traceback (most recent call last)
in
1 import os
—-> 2 import cv2
3 import numpy as np
4 from matplotlib import pyplot as plt
5 get_ipython().run_line_magic(‘matplotlib’, ‘inline’)

ModuleNotFoundError: No module named ‘cv2’
`

gowrusreevathsa commented Nov 25, 2019 •

This helped me.
I created a new cv-nd environment using the command conda create -n yourenvname python=x.x anaconda . The env name is cv-nd and I didn’t specify python version so my command looked conda create -n cv-nd anaconda .
Then activate the environment using conda activate cv-nd .
Then install required libraries using conda commands. I installed jupyter and cv2 in this environment. You can find commands for cv2 at https://anaconda.org/conda-forge/opencv Navigate that website as per your requirement.

I don’t know why jupyter isn’t working for me using cli in the environment. Anyway, typing jupyter in windows search shows Jupyter of cv-nd environment. Click on it and everything’s importing as expected.

gowrusreevathsa commented Nov 25, 2019

i follow the step of @sunsided and @cezannec but still faced same problem.module cv2 is not found.plz help me to figure out this.`ModuleNotFoundError Traceback (most recent call last)
in
1 import os
—-> 2 import cv2
3 import numpy as np
4 from matplotlib import pyplot as plt
5 get_ipython().run_line_magic(‘matplotlib’, ‘inline’)

ModuleNotFoundError: No module named ‘cv2’
`

Try following the method I mentioned above. It might work for you.

Kamil2412 commented May 15, 2020

OpenCV is compiled for Python 2.7. When you install it with pip, it will install 2.7. However, if you run the code with python 3, it will complain that the module is not installed.
using the command
sudo apt-get install python3-opencv

Читайте также:  Windows 10 не работает сетевой драйвер

Solved my problem, hope it will help others

leohfigueiredo commented Jul 8, 2020

conda install nb_conda works for me. Thanks.

KFatma commented Nov 17, 2020

pip install opencv-python
This worked for me!

sanskarfc commented Jan 9, 2021

It could be that it’s not picking up your environment. If that is true, try installing nb_conda within your environment and then start Jupyter from there.

Источник

Оцените статью