简体   繁体   中英

Installing opencv 3.4.2 with Anaconda

I'm running Ubuntu 18.04LTS:

Firstly, I couldn't install opencv from anaconda on my existing environment (base) as it kept searching for conflicts forever and then getting stuck with an empty window saying "these packages will be modified" while displaying absolutely nothing and with the only choice of pressing the "cancel" button. I created a new virtual environment named env_opencv and was able to install opencv: enter image description here

Then, I run a jupyter notebook that imports opencv:

import cv2
import matplotlib.pyplot as plt
import matplotlib.patches as patches
 ...

And here's what I get:

ModuleNotFoundError                       Traceback (most recent call last)
<ipython-input-8-31cd2c78c525> in <module>
----> 1 import cv2
      2 import matplotlib.pyplot as plt
      3 import matplotlib.patches as patches
     4 
     5 from align import AlignDlib

ModuleNotFoundError: No module named 'cv2'

No matter what I tried, including reinstalling opencv directly from the conda prompt, I can't get past this error.

Incidentally, I was able to make it work on Windows 10 going through the Anaconda prompt and using conda. However, my Windows machine doesn't have an nVidia GPU and I can't use it for CNN training, so I really need to make it work on Ubuntu.

Any suggestions would be great. Thank you.

I found a workaround to this issue: I activate the env_opencv environment from the command line, then I launch jupyter notebook and it works. Maybe, there is a bug with anaconda-navigator that doesn't seem to switch environments from the GUI?

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