Micheal Bee
Micheal Bee

Reputation: 628

I can't import cv2 from a conda environment

I installed opencv 4.3.0-dev on Ubuntu 18,04. I built it from the latest branch on Github. I installed it without any virtual environment activated. When I run the following, I get the correct output:

python3 -c "import cv2; print(cv2.__version__)"
4.3.0-dev 

If I create a conda environment conda create --name foo python-3.6 and activate it, I get this:

python3 -c "import cv2; print(cv2.__version__)"
Traceback (most recent call last):
  File "<string>", line 1, in <module>
ModuleNotFoundError: No module named 'cv2' 

Neither pip list nor conda list shows the cv2 module in either case. Where is cv2, and how can I import it into a conda virtual environment?

Upvotes: 1

Views: 847

Answers (1)

Karan Mishra
Karan Mishra

Reputation: 26

I have also faced the same problem. I just deleted the existing openCV file and then created a conda evironment. After that i just typed: conda install openCv (in the terminal) And the package was successfully installed in that conda environment.

Upvotes: 1

Related Questions