导入错误:DLL加载失败。找不到指定的模块

2024-10-03 11:15:21 发布

您现在位置:Python中文网/ 问答频道 /正文

我是python的初学者。我已经在笔记本电脑上安装了python,其版本是win32上的python 2.7.18(v2.7.18:8d21aa21f2,2020年4月20日,13:19:08)[MSC v.1500 32位(英特尔)]。我正在尝试导入其他人创建的现有框架,并使用现有包创建一个新的示例python文件。我写了一句简单的话:

 from machine_lib.pydblib import db

pydblib是从SWIG自动生成的文件。以下代码取自SWIG文件:

from sys import version_info as _swig_python_version_info
if _swig_python_version_info >= (2, 7, 0):
    def swig_import_helper():
        import importlib
        pkg = __name__.rpartition('.')[0]
        mname = '.'.join((pkg, '_pydblib')).lstrip('.')
        try:
            return importlib.import_module(mname)
        except ImportError:
            return importlib.import_module('_pydblib')
    _pydblib = swig_import_helper()

错误位于except块:return importlib.import_module('_pydblib'),该块表示:

ImportError: DLL load failed: The specified module could not be found in pycharm.

我已经检查了同一个错误的答案,但没有任何效果。我怎样才能消除这个错误?如果需要,我很乐意分享更多信息。提前谢谢


Tags: 文件fromimportinfohelperreturnversion错误
1条回答
网友
1楼 · 发布于 2024-10-03 11:15:21

相关说明如果您来这里搜索“python”、“导入错误”和“DLL加载失败”:在Python 3.8 DLL resolution under Windows has changed。另见what's new in Python 3.8

DLL dependencies for extension modules and DLLs loaded with ctypes on Windows are now resolved more securely. Only the system paths, the directory containing the DLL or PYD file, and directories added with add_dll_directory() are searched for load-time dependencies. Specifically, PATH and the current working directory are no longer used, and modifications to these will no longer have any effect on normal DLL resolution. If your application relies on these mechanisms, you should check for add_dll_directory() and if it exists, use it to add your DLLs directory while loading your library. Note that Windows 7 users will need to ensure that Windows Update KB2533623 has been installed (this is also verified by the installer).

您还可以使用ProcessMonitor检查Python正在查找的DLL的名称

相关问题 更多 >