【发布时间】:2017-05-20 18:56:23
【问题描述】:
我在 Windows 10 下使用 Visual Studio 2017 从源代码构建了 OpenCV 3.2,它在构建目录中生成了一个文件 cv2.cp36-win_amd64.pyd,并将其复制到 C:\Users\fanta\Anaconda3\Lib\site-packages。
但是现在进入 Python 3.6 的 Anaconda 环境后,python 找不到包,请看下面的脚本(底部有错误):
C:\Users\fanta>conda create -n py36 python=3.6
Fetching package metadata ...........
Solving package specifications: .
Package plan for installation in environment C:\Users\fanta\Anaconda3\envs\py36:
The following NEW packages will be INSTALLED:
pip: 9.0.1-py36_1
python: 3.6.1-2
setuptools: 27.2.0-py36_1
vs2015_runtime: 14.0.25123-0
wheel: 0.29.0-py36_0
Proceed ([y]/n)?
#
# To activate this environment, use:
# > activate py36
#
# To deactivate this environment, use:
# > deactivate py36
#
# * for power-users using bash, you must source
#
C:\Users\fanta>activate py36
(py36) C:\Users\fanta>python
Python 3.6.1 |Continuum Analytics, Inc.| (default, May 11 2017, 13:25:24) [MSC v.1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import cv2
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'cv2'
>>>
如果我尝试从任何 Anaconda 环境之外导入 cv2 包,则会收到不同的错误,请参见下文:
(py36) C:\Users\fanta>deactivate py36
C:\Users\fanta>python
Python 3.6.0 |Anaconda 4.3.1 (64-bit)| (default, Dec 23 2016, 11:57:41) [MSC v.1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import cv2
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: DLL load failed: The specified module could not be found.
>>>
如何使构建的cv2 包可以导入到 Anaconda 环境中?
谢谢!
【问题讨论】: