I installed python 3.35 and I'm getting this error:
我安装了python 3.35,我得到了这个错误:
Traceback (most recent call last):
File "C:/Users/Augusto/PycharmProjects/Plot/Database.py", line 48, in <module>
import socket
File "C:\Python33\lib\socket.py", line 47, in <module>
import _socket
ImportError: DLL load failed: The specified module could not be found
I'm running it on Windows 7 64 bits. I tried both Python installations (Windows x86-64 MSI installer and Windows x86 MSI installer) but both present the same error. I removed the python 2.7 installation from the path in the chance it was causing the error, but no luck.
我在Windows 7 64位上运行它。我尝试了两个Python安装(Windows x86-64 MSI安装程序和Windows x86 MSI安装程序),但都出现了相同的错误。我从path中删除了python 2.7安装,因为它可能导致错误,但是没有运气。
EDIT: os.system('listdlls %d' % os.getpid())
编辑:操作系统。系统(“listdlls % d ' % os.getpid())
Base Size Path
0x000000001d000000 0xa000 C:\Python33\python.exe
0x0000000077b40000 0x1a9000 C:\Windows\SYSTEM32\ntdll.dll
0x00000000756f0000 0x3f000 C:\Windows\SYSTEM32\wow64.dll
0x0000000075690000 0x5c000 C:\Windows\SYSTEM32\wow64win.dll
0x0000000075680000 0x8000 C:\Windows\SYSTEM32\wow64cpu.dll
0x000000001d000000 0xa000 C:\Python33\python.exe
0x0000000077d20000 0x180000 C:\Windows\SysWOW64\ntdll.dll
0x0000000076b80000 0x110000 C:\Windows\syswow64\kernel32.dll
0x0000000076a20000 0x47000 C:\Windows\syswow64\KERNELBASE.dll
0x000000001e000000 0x294000 C:\Windows\SysWOW64\python33.dll
0x0000000075880000 0x100000 C:\Windows\syswow64\USER32.dll
0x0000000076500000 0x90000 C:\Windows\syswow64\GDI32.dll
0x0000000076b00000 0xa000 C:\Windows\syswow64\LPK.dll
0x0000000076760000 0x9d000 C:\Windows\syswow64\USP10.dll
0x0000000076800000 0xac000 C:\Windows\syswow64\msvcrt.dll
0x00000000768b0000 0xa0000 C:\Windows\syswow64\ADVAPI32.dll
0x0000000076590000 0x19000 C:\Windows\SysWOW64\sechost.dll
0x0000000076400000 0xf0000 C:\Windows\syswow64\RPCRT4.dll
0x0000000075750000 0x60000 C:\Windows\syswow64\SspiCli.dll
0x0000000075740000 0xc000 C:\Windows\syswow64\CRYPTBASE.dll
0x0000000076cd0000 0xc4a000 C:\Windows\syswow64\SHELL32.dll
0x0000000076700000 0x57000 C:\Windows\syswow64\SHLWAPI.dll
0x0000000062ba0000 0xbf000 C:\Windows\SysWOW64\MSVCR100.dll
0x0000000076050000 0x60000 C:\Windows\SysWOW64\IMM32.DLL
0x00000000757b0000 0xcc000 C:\Windows\syswow64\MSCTF.dll
0x00000000755d0000 0x35000 C:\Windows\SysWOW64\nvinit.dll
0x000000000f000000 0x6000 C:\Program Files (x86)\NVIDIA Corporation\CoProcManager\detoured.dll
0x00000000739f0000 0x4c000 C:\Program Files (x86)\NVIDIA Corporation\CoProcManager\nvd3d9wrap.dll
0x0000000075d80000 0x19d000 C:\Windows\syswow64\SETUPAPI.dll
0x0000000076c90000 0x27000 C:\Windows\syswow64\CFGMGR32.dll
0x0000000075990000 0x8f000 C:\Windows\syswow64\OLEAUT32.dll
0x00000000760b0000 0x15c000 C:\Windows\syswow64\ole32.dll
0x0000000075d60000 0x12000 C:\Windows\syswow64\DEVOBJ.dll
0x00000000739b0000 0x33000 C:\Program Files (x86)\NVIDIA Corporation\CoProcManager\nvdxgiwrap.dll
0x0000000074010000 0x16000 C:\Windows\SysWOW64\CRYPTSP.dll\rsaenh.dll
0x0000000066480000 0x15000 C:\Python33\DLLs\python3.dll
0x0000000065990000 0x41000 C:\Python33\lib\site-packages\PyQt4\QtSql.pyd
0x000000006a350000 0x34000 C:\Python33\lib\site-packages\PyQt4\QtSql4.dll
0x000000006a4f0000 0x273000 C:\Python33\lib\site-packages\PyQt4\QtCore4.dll
0x0000000076b10000 0x35000 C:\Windows\syswow64\WS2_32.dll
0x00000000763f0000 0x6000 C:\Windows\syswow64\NSI.dll
0x000000006f3d0000 0x69000 C:\Windows\SysWOW64\MSVCP100.dll
0x00000000685c0000 0x80d000 C:\Python33\lib\site-packages\PyQt4\QtGui4.dll
0x0000000076990000 0x7b000 C:\Windows\syswow64\COMDLG32.dll
0x0000000073270000 0x84000 C:\Windows\WinSxS_microsoft.windows.common-controls_6595b64144ccf1df_5.82.7601.18201_none_ec80f00e8593ece5\COMCTL32.dll
0x00000000718f0000 0x32000 C:\Windows\SysWOW64\WINMM.dll
0x0000000075610000 0x51000 C:\Windows\SysWOW64\WINSPOOL.DRV
0x0000000065970000 0x15000 C:\Python33\lib\site-packages\sip.pyd
0x0000000050d20000 0x19c000 C:\Python33\lib\site-packages\PyQt4\QtCore.pyd
0x0000000050770000 0x5ad000 C:\Python33\lib\site-packages\PyQt4\QtGui.pyd
0x0000000073bd0000 0x4c000 C:\Windows\SysWOW64pphelp.dll
1 个解决方案
#1
4
The output from listdlls.exe shows that there's no problem loading the dependency ws2_32.dll (Winsock), which would be surprising to say the least. So the problem is that it's trying to load the wrong _socket.pyd.
listdlls的输出。exe表明加载依赖项ws2_32没有问题。dll (Winsock),这至少可以说是令人惊讶的。问题是,它试图加载错误的_socket.pyd。
In the comments it was confirmed that loading _socket.pyd worked when an absolute path was passed to imp.load_dynamic
. It turns out that the system had the environment variable PYTHONPATH
set to include C:\Python27\DLLs
. The solution was to simply unset this environment variable.
在评论中,它确认了加载_socket。当一个绝对路径传递给impl .load_dynamic时,pyd工作。结果表明,该系统的环境变量PYTHONPATH集包含了C:\Python27\ dll。解决方案是简单地取消这个环境变量。
I was thrown off by the error message. Normally such a case would raise an error that the shared library is compiled for a different Python version. However, _socket.pyd for Python 2.7 links with msvcr90.dll. This DLL isn't on the DLL search path. It's in a subdirectory of %windir%\WinSxS
. It's found by consulting the activation context of C:\Python27\python.exe
, which specifies the C runtime dependency in its embedded manifest:
我被错误信息弄丢了。通常情况下,这样的情况会引起一个错误,即为不同的Python版本编译共享库。然而,_socket。pyd用于Python 2.7与msvcr90.dll的链接。这个DLL不在DLL搜索路径上。它在%windir%\WinSxS的子目录中。它是通过咨询C:\Python27\python的激活上下文找到的。exe,它在其嵌入的清单中指定了C运行时依赖项:
<dependency>
<dependentAssembly>
<assemblyIdentity
type="win32"
name="Microsoft.VC90.CRT"
version="9.0.21022.8"
processorArchitecture="x86"
publicKeyToken="1fc8b3b9a1e18e3b">
</assemblyIdentity>
</dependentAssembly>
</dependency>
So when running under C:\Python33\python.exe
, trying to load the 2.7 _socket.pyd raises the following exception:
所以当运行在C:\Python33\python的时候。exe,尝试加载2.7 _socket。pyd提出以下例外:
>>> imp.load_dynamic('_socket', r'C:\Python27\DLLs\_socket.pyd')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: DLL load failed: The specified module could not be found.
3.3 and 3.4 are built with Visual Studio 2010 instead of 2008, which switched back to installing msvcr100.dll on the normal search path. So for comparison here's the error I get when I try to import the 3.3 version of _socket.pyd
within 3.4:
3.3和3.4是用Visual Studio 2010而不是2008年构建的,而2008年改为安装msvcr100。在正常搜索路径上的dll。比较一下,当我尝试导入3.3版本的_socket时,我得到了错误。pyd内3.4:
>>> imp.load_dynamic('_socket', r'C:\Python33\DLLs\_socket.pyd')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: Module use of python33.dll conflicts with this version of Python.
#1
4
The output from listdlls.exe shows that there's no problem loading the dependency ws2_32.dll (Winsock), which would be surprising to say the least. So the problem is that it's trying to load the wrong _socket.pyd.
listdlls的输出。exe表明加载依赖项ws2_32没有问题。dll (Winsock),这至少可以说是令人惊讶的。问题是,它试图加载错误的_socket.pyd。
In the comments it was confirmed that loading _socket.pyd worked when an absolute path was passed to imp.load_dynamic
. It turns out that the system had the environment variable PYTHONPATH
set to include C:\Python27\DLLs
. The solution was to simply unset this environment variable.
在评论中,它确认了加载_socket。当一个绝对路径传递给impl .load_dynamic时,pyd工作。结果表明,该系统的环境变量PYTHONPATH集包含了C:\Python27\ dll。解决方案是简单地取消这个环境变量。
I was thrown off by the error message. Normally such a case would raise an error that the shared library is compiled for a different Python version. However, _socket.pyd for Python 2.7 links with msvcr90.dll. This DLL isn't on the DLL search path. It's in a subdirectory of %windir%\WinSxS
. It's found by consulting the activation context of C:\Python27\python.exe
, which specifies the C runtime dependency in its embedded manifest:
我被错误信息弄丢了。通常情况下,这样的情况会引起一个错误,即为不同的Python版本编译共享库。然而,_socket。pyd用于Python 2.7与msvcr90.dll的链接。这个DLL不在DLL搜索路径上。它在%windir%\WinSxS的子目录中。它是通过咨询C:\Python27\python的激活上下文找到的。exe,它在其嵌入的清单中指定了C运行时依赖项:
<dependency>
<dependentAssembly>
<assemblyIdentity
type="win32"
name="Microsoft.VC90.CRT"
version="9.0.21022.8"
processorArchitecture="x86"
publicKeyToken="1fc8b3b9a1e18e3b">
</assemblyIdentity>
</dependentAssembly>
</dependency>
So when running under C:\Python33\python.exe
, trying to load the 2.7 _socket.pyd raises the following exception:
所以当运行在C:\Python33\python的时候。exe,尝试加载2.7 _socket。pyd提出以下例外:
>>> imp.load_dynamic('_socket', r'C:\Python27\DLLs\_socket.pyd')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: DLL load failed: The specified module could not be found.
3.3 and 3.4 are built with Visual Studio 2010 instead of 2008, which switched back to installing msvcr100.dll on the normal search path. So for comparison here's the error I get when I try to import the 3.3 version of _socket.pyd
within 3.4:
3.3和3.4是用Visual Studio 2010而不是2008年构建的,而2008年改为安装msvcr100。在正常搜索路径上的dll。比较一下,当我尝试导入3.3版本的_socket时,我得到了错误。pyd内3.4:
>>> imp.load_dynamic('_socket', r'C:\Python33\DLLs\_socket.pyd')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: Module use of python33.dll conflicts with this version of Python.