无法在Python 3.5上导入cv2 DLL加载失败

时间:2017-04-14 22:03:08

标签: python c++ opencv

我一直在努力解决这个问题,并且找不到有效的解决方案。当我用python-v导入cv2时,我得到了

>>> import cv2 Traceback (most recent call last): 
File "<stdin>", line 1, in <module> File "<frozen importlib._bootstrap>", 
line 969, in _find_and_load File "<frozen importlib._bootstrap>", 
line 958, in _find_and_load_unlocked File "<frozen importlib._bootstrap>", 
line 666, in _load_unlocked File "<frozen importlib._bootstrap>", 
line 577, in module_from_spec File "<frozen importlib._bootstrap_external>", 
line 914, in create_module File "<frozen importlib._bootstrap>", 
line 222, in _call_with_frames_removed 
ImportError: DLL load failed: The specified module could not be found.

我在Windows 10 64位上使用带有Anaconda3的Python 3.5。关于这一点,我已经浏览了stackoverflow上的所有其他帖子。基于此,这里是我所做的事情的一些信息:

  1. 我在VC ++ 2015独立工具中安装了Visual Studio 14.0 http://landinghub.visualstudio.com/visual-cpp-build-tools

  2. 我删除了旧的C ++可再发行软件包并安装了https://www.microsoft.com/en-gb/download/details.aspx?id=48145。我的msvcp140.dll出现在这里:C:\ Program Files(x86)\ Microsoft Visual Studio 14.0 \ VC \ redist \ x64 \ Microsoft.VC140.CRT

  3. 我从此链接https://pypi.python.org/pypi/opencv-python#downloads

  4. 安装了opencv python
  5. 我将cv2.pyd包复制到我的Lib / site-package目录中

  6. 有关我失踪的建议吗? 在此先感谢!!

1 个答案:

答案 0 :(得分:2)

建议从此Unofficial Windows Binaries for Python Extension Packages网站OpenCV 3.2.0Python 3.5 32-bit下载64-bit opencv_python‑3.2.0+contrib‑cp35‑cp35m。为您的案例查找后缀为+contrib的文件。 pip install opencv_python‑3.2.0+contrib‑cp35‑cp35m‑win32.whl是具有opencv_contrib模块的那些。

然后输入以下命令从您的位置驱动器安装二进制文件:

  • pip install opencv_python‑3.2.0+contrib‑cp35‑cp35m‑win_amd64.whl(32位 版本)或
  • conda env(64位版本)

在安装此二进制文件之前,请确保已完全删除以前的安装,或者您可以创建一个新的conda list来安装它。如果已成功安装,它将显示在import cv2中。然后,您可以按print cv2.__version__asio::io_service io_service; asio::ip::tcp::socket s(io_service); asio::ip::tcp::resolver resolver(io_service); asio::connect(s, resolver.resolve({ "aire.pl", "80" })); cout << "connected" << endl; string request = "GET http://aire.pl/ HTTP/1.1"; size_t request_length = std::strlen(request.c_str()); asio::write(s, asio::buffer(request, request_length)); cout << "packet sent" << endl; char reply[1024]; size_t reply_length = asio::read(s, asio::buffer(reply, request_length)); std::cout << "Reply is: "; std::cout.write(reply, reply_length); std::cout << "\n"; 检查其版本。