简体   繁体   English

使用 Anaconda 安装 opencv 3.4.2

[英]Installing opencv 3.4.2 with Anaconda

I'm running Ubuntu 18.04LTS:我正在运行 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.首先,我无法在我现有的环境(基础)上从 anaconda 安装 opencv,因为它一直在寻找冲突,然后卡在一个空窗口中,说“这些包将被修改”,同时什么也不显示,唯一的选择是按“取消”按钮。 I created a new virtual environment named env_opencv and was able to install opencv: enter image description here我创建了一个名为 env_opencv 的新虚拟环境并且能够安装 opencv:在此处输入图像描述

Then, I run a jupyter notebook that imports opencv:然后,我运行一个导入 opencv 的 jupyter notebook:

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.无论我尝试什么,包括直接从 conda 提示符重新安装 opencv,我都无法克服这个错误。

Incidentally, I was able to make it work on Windows 10 going through the Anaconda prompt and using conda.顺便说一句,我能够通过 Anaconda 提示并使用 conda 使其在 Windows 10 上运行。 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.但是,我的 Windows 机器没有 nVidia GPU,我不能将它用于 CNN 训练,所以我真的需要让它在 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.我找到了解决此问题的方法:我从命令行激活 env_opencv 环境,然后启动 jupyter notebook 并且它工作正常。 Maybe, there is a bug with anaconda-navigator that doesn't seem to switch environments from the GUI?也许,anaconda-navigator 存在一个错误,似乎无法从 GUI 切换环境?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM