Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/334.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
OSError:[WinError 127]尝试加载DLL时,通过更改环境[Python]修复_Python_Dll_Mingw_Ctypes - Fatal编程技术网

OSError:[WinError 127]尝试加载DLL时,通过更改环境[Python]修复

OSError:[WinError 127]尝试加载DLL时,通过更改环境[Python]修复,python,dll,mingw,ctypes,Python,Dll,Mingw,Ctypes,我已经尝试在64位python环境中使用现有的python绑定使tree sitter解析库在我的项目中工作,但遗憾的是没有成功。github发布的python绑定报告提到,该库仅与32位python版本兼容。因为库需要在解析任何东西之前首先将解析器编译成DLL,所以我将MinGW安装为32位C(++)编译器,并设法编译解析器。但是,在尝试加载DLL时,我出现以下错误: File "D:\Projekte\Idea\Crawler\venv37\lib\site-packages\tr

我已经尝试在64位python环境中使用现有的python绑定使tree sitter解析库在我的项目中工作,但遗憾的是没有成功。github发布的python绑定报告提到,该库仅与32位python版本兼容。因为库需要在解析任何东西之前首先将解析器编译成DLL,所以我将MinGW安装为32位C(++)编译器,并设法编译解析器。但是,在尝试加载DLL时,我出现以下错误:

File "D:\Projekte\Idea\Crawler\venv37\lib\site-packages\tree_sitter\__init__.py",
 line 81, in __init__
     self.lib = cdll.LoadLibrary(library_path)  
File "C:\Program Files (x86)\Python37\lib\ctypes\__init__.py", line 442, in LoadLibrary      
     return self._dlltype(name)     
File "C:\Program Files (x86)\Python37\lib\ctypes\__init__.py", line 364, in __init__
     self._handle = _dlopen(self._name, mode) 
OSError: [WinError 127] Die angegebene Prozedur wurde nicht gefunden 
在上进行了一点搜索之后,我通过添加
os.environ['PATH']=“C:/MinGW/bin”+;“+在尝试加载DLL之前,将os.environ['PATH']
添加到我的代码中。我想这是因为我首先使用MinGW编译DLL。 为了完整起见:我确实更改了Python37/lib/distutils/cygwingcompiler.py中的一些代码行,以强制python实际使用适当的编译器,即将类
Mingw32CCompiler
中的可执行链接器更改为“g++-shared”,并添加

elif msc_ver == '1926':
    # Visual Studio 2015 / Visual C++ 14.0
    # "msvcr140.dll no longer exists" http://blogs.msdn.com/b/vcblog/archive/2014/06/03/visual-studio-14-ctp.aspx
    return ['vcruntime140']
获取msvcr()

我仍然不太清楚为什么这修复了错误,试图使用调试器遍历堆栈跟踪只会让我迷失在
ctypes/\uuuu init\uuuuuuuuy.py
中无数的存根中。我想这篇文章可以帮助其他遇到类似错误的人和我自己更好地理解到底发生了什么