python - 如何在 Python 上解析 "ImportError: DLL load failed:"?

标签 python pip importerror ddl

最近,当我导入不同的库(例如 scikit-learnscipy 和其他一些)。

我的假设是我在尝试 pip install opencv 时损坏了一些东西。

那么,我的问题是如何解决这个似乎不是库特定的问题?

我可以 pip 安装 DLL 或类似的东西吗?我可以重新安装整个 Python 吗?我在 Windows 上工作。我的 Python 版本是 Python 2.7.10::Anaconda 2.3.0(64 位)

已添加

如果我打印 sys.path 我得到这个:

['',
 'C:\\Anaconda\\Scripts',
 'C:\\Anaconda\\python27.zip',
 'C:\\Anaconda\\DLLs',
 'C:\\Anaconda\\lib',
 'C:\\Anaconda\\lib\\plat-win',
 'C:\\Anaconda\\lib\\lib-tk',
 'C:\\Anaconda',
 'C:\\Anaconda\\lib\\site-packages',
 'C:\\Anaconda\\lib\\site-packages\\Sphinx-1.3.1-py2.7.egg',
 'C:\\Anaconda\\lib\\site-packages\\cryptography-0.9.1-py2.7-win-amd64.egg',
 'C:\\Panda3D-1.9.2-x64',
 'C:\\Panda3D-1.9.2-x64\\bin',
 'C:\\Anaconda\\lib\\site-packages\\win32',
 'C:\\Anaconda\\lib\\site-packages\\win32\\lib',
 'C:\\Anaconda\\lib\\site-packages\\Pythonwin',
 'C:\\Anaconda\\lib\\site-packages\\setuptools-17.1.1-py2.7.egg',
 'C:\\Anaconda\\lib\\site-packages\\IPython\\extensions',
 'C:\\Users\\myname\\.ipython']

让我担心的是混合了 32 位和 64 位版本。另一件事,也许我只是有不同的 Python,我只需要调用正确的 Python?

最佳答案

如果有人在使用 Windows 的 Python > 3.8 中遇到此问题,dll 仅从受信任的位置加载 https://docs.python.org/3/whatsnew/3.8.html#ctypes 这可以通过使用 os.add_dll_directory("PATH_TO_DLL")

添加 dll 路径来解决

关于python - 如何在 Python 上解析 "ImportError: DLL load failed:"?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41365446/

相关文章:

python - 如何在 Windows 上获取 uwsgi

python - "AssertionError: Only python 2.7 and later is supported by ptyprocess",在 python 2.6 上通过 pip 安装 pexpect 时

python - colab中的torchtext ImportError

python - Win 7中的greenlet : DLL failed: the specified procedure could not be found

Python Selenium GUI 到可执行文件

Python/Pandas –– ParserError : Error tokenizing data. C 错误 : Expected x fields in line i, 看到 y

python - matplotlib stepfilled 直方图在 xubuntu 的值 10^-1 处中断

python - 向 DataFrame 添加多行的有效方法

python - 在 Bluehost 上安装 Django

python - 导入错误。没有名为 Commons 的模块错误 - python