gpt4 book ai didi

python - 使用 pycrypto 时没有名为 'winrandom' 的模块

转载 作者:IT老高 更新时间:2023-10-28 22:23:43 27 4
gpt4 key购买 nike

我已经花了 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,它不关心大写。我将文件夹名称从加密更改为加密,这个特定问题消失了。

现在它想要 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

关于python - 使用 pycrypto 时没有名为 'winrandom' 的模块,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24804829/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com