使用pycrypto时没有名为“winrandom”的模块

我已经花了2天试图为Paramiko模块安装pyCrypto。

所以,我遇到的第一个问题是:

>>> import paramiko Traceback (most recent call last): File "<stdin>", line 1, in <module> File "C:\Program Files\Python\lib\site-packages\paramiko\__init__.py", line 31 , in <module> from paramiko.transport import SecurityOptions, Transport File "C:\Program Files\Python\lib\site-packages\paramiko\transport.py", line 4 7, in <module> from paramiko.dsskey import DSSKey File "C:\Program Files\Python\lib\site-packages\paramiko\dsskey.py", line 26, in <module> from Crypto.PublicKey import DSA ImportError: No module named 'Crypto' 

这实际上是非常有趣的,因为我使用Windows,它不关心大写字母。 我把密码文件夹的名字从crypto改成了Crypto,这个问题就消失了。

现在它想winrandom:

 Traceback (most recent call last): File "<stdin>", line 1, in <module> File "C:\Program Files\Python\lib\site-packages\paramiko\__init__.py", line 31 , in <module> from paramiko.transport import SecurityOptions, Transport File "C:\Program Files\Python\lib\site-packages\paramiko\transport.py", line 4 7, in <module> from paramiko.dsskey import DSSKey File "C:\Program Files\Python\lib\site-packages\paramiko\dsskey.py", line 26, in <module> from Crypto.PublicKey import DSA File "C:\Program Files\Python\lib\site-packages\Crypto\PublicKey\DSA.py", line 89, in <module> from Crypto import Random File "C:\Program Files\Python\lib\site-packages\Crypto\Random\__init__.py", li ne 28, in <module> from Crypto.Random import OSRNG File "C:\Program Files\Python\lib\site-packages\Crypto\Random\OSRNG\__init__.p y", line 34, in <module> from Crypto.Random.OSRNG.nt import new File "C:\Program Files\Python\lib\site-packages\Crypto\Random\OSRNG\nt.py", li ne 28, in <module> import winrandom ImportError: No module named 'winrandom' 

当我尝试通过PIP安装时,我失败了:

 Cannot export PyInit_winrandom: symbol not defined build\temp.win32-3.4\Release\src\winrandom.o:winrandom.c:(.text+0x12): undefined reference to `Py_InitModule' collect2: ld returned 1 exit status error: command 'c:\\mingw\\bin\\gcc.exe' failed with exit status 1 

似乎它不支持Python3.4。

有没有什么办法使得它可以在安装了Python3.4的Win7 x86中运行?

安装模块:

 crypto (1.1.0) ecdsa (0.11) Fabric (1.9.0) paramiko (1.14.0) pip (1.5.6) pyasn1 (0.1.7) pycrypto (2.6.1) PyYAML (3.11) rsa (3.1.4) setuptools (2.1) 

Python版本3.4.1

Solutions Collecting From Web of "使用pycrypto时没有名为“winrandom”的模块"

问题可以通过在crypto \ Random \ OSRNG \ nt.py中编辑字符串来解决:

 import winrandom 

 from . import winrandom 

超级简单的修复ImportError: No module named 'winrandom' – 这是Python在我的Windows 10系统上的位置:

C:\Users\Charles\AppData\Local\Programs\Python\Python35

但你必须进一步找到正确的文件来更新,所以去这里:

C:\Users\Charles\AppData\Local\Programs\Python\Python35\Lib\site-packages\Crypto\Random\OSRNG\nt.py

在任何文本编辑器中打开nt.py ,并只改变顶部附近的行:

 import winrandom 

应该:

 from . import winrandom 

保存文件 – 重新运行你最初试图运行,你应该是好的。 希望这可以帮助别人!