我已经花了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
通过在crypto \ Random \ OSRNG \ nt.py中编辑字符串可以解决问题:
import winrandom
至
from . import winrandom