user3849304 user3849304 - 3 months ago 66
Python Question

Another one about pyCrypto and Paramiko

I already spent 2 days trying to install pyCrypto for Paramiko module.

So, first issue I had faced was this:

>>> 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'


It is very fun actually because I use Windows and it doesn't care about uppercase. I changed a folder name from crypto to Crypto and this particular issue disappeared.

Now it wants 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'


When I try to install it through PIP I fail with:

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


Seems like it doesn't support Python3.4.

Is there any way to make it all works in Win7 x86 with Python3.4 installed?

Installed modules:

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 version 3.4.1

Answer

Problem is solved by editing string in crypto\Random\OSRNG\nt.py:

import winrandom

to

from . import winrandom
Comments