我在安装Anaconda之后,在vcpkg中添加了这个问题。
G:\vcpkg_common\downloads\tools\python>G:\vcpkg_common\downloads\tools\python\python-3.11.5-x64\python.exe
Python 3.11.5 (tags/v3.11.5:cce6ba9, Aug 24 2023, 14:38:34) [MSC v.1936 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import _ctypes
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: DLL load failed while importing _ctypes: Das angegebene Modul wurde nicht gefunden.
我故意更改了
CWD
,因为如果我在与我想要使用的Python相同的目录中,一切都能按预期工作。
向Python提供
-E
选项使其正常工作:
G:\vcpkg_common\downloads\tools\python>G:\vcpkg_common\downloads\tools\python\python-3.11.5-x64\python.exe -E
Python 3.11.5 (tags/v3.11.5:cce6ba9, Aug 24 2023, 14:38:34) [MSC v.1936 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import _ctypes
>>> exit()
然而,
-E
选项不应该起作用,因为没有设置相关的环境变量。
G:\vcpkg_common\downloads\tools\python>set | findstr PY
G:\vcpkg_common\downloads\tools\python>
查看sys.path,然而揭示了以下内容:
>>> sys.path
['', 'G:\\vcpkg_common\\downloads\\tools\\python\\python-3.11.5-x64\\python311.zip', 'C:\\Python\\anaconda3\\Lib', 'C:\\Python\\anaconda3\\DLLs', 'G:\\vcpkg_common\\downloads\\tools\\python\\python-3.11.5-x64', 'G:\\vcpkg_common\\downloads\\tools\\python\\python-3.11.5-x64\\Lib', 'C:\\Users\\neumann\\AppData\\Roaming\\Python\\Python311\\site-packages']
在错误情况下和
>>> sys.path
['', 'G:\\vcpkg_common\\downloads\\tools\\python\\python-3.11.5-x64\\python311.zip', 'G:\\vcpkg_common\\downloads\\tools\\python\\python-3.11.5-x64', 'G:\\vcpkg_common\\downloads\\tools\\python\\python-3.11.5-x64\\Lib', 'C:\\Users\\neumann\\AppData\\Roaming\\Python\\Python311\\site-packages']
在工作情况下,尝试从Anaconda位置加载DLL时出现错误,因为其路径在内置路径之前,导致观察到的错误。
在搜索注册表后,我发现:
HKEY_LOCAL_MACHINE\SOFTWARE\Python\PythonCore\3.11\PythonPath
似乎是导致并行安装中断的原因。
dir "C:\Users\shing\anaconda3\DLLs\_ctypes.pyd"
,会输出什么?另外一个环境也是Python 3.10.0吗? - CristiFati