pycrypto 在 python3.9 安裝失敗,No module named 'winrandom'

不知道爲什麼,非要把 pycrypto 安裝搞得這麼複雜……

pycrypto, 主要用來加解密

python安裝pycrypto時報cl.exe錯誤返回狀態2

一、安裝 vs tool

下載 vs build tool 

建議C盤可用空間不低於20G,安裝的時候選擇默認路徑,勾選自己需要安裝的 文件

 

安裝完成後

 

Program Files (x86)\Microsoft Visual Studio\20XX\Community\VC\Tools\MSVC\14.xxxxx\include\

20XX 這個是根據安裝的版本不一樣自己找,有2017、2019等,可能後續會有2021

14.xxxxx  這個是根據安裝的版本不一樣自己找,14表示的是 vc 14

找到 stdint.h 文件,
拷貝到

Program Files (x86)\Windows Kits\10\Include\10.0.xxxx.xx\ucrt\

10.0.xxxx.xx  這個是根據安裝的版本不一樣自己找

然後在該目錄找到  inttypes.h  這個文件,一般情況下是不能在當前目錄修改,複製到桌面,

#include <stdint.h>

修改爲

#include "stdint.h"

該 雙引號 爲 英文格式

把修改後的文件移入剛纔的目錄,一般是需要管理員權限的,確認就可以

 

二、 安裝  wheel 

如果不安裝 wheel  ,會出現以下的警告,後面可能會影響其他的操作,

Using legacy 'setup.py install' for pycrypto, since package 'wheel' is not installed

操作

pip install wheel

 

三、安裝  pycrypto

pip install pycrypto

 

四、引用 pycrypto 的時候出現

ModuleNotFoundError: No module named 'winrandom'

修改python安裝目錄下的 python\Lib\site-packages\Crypto\Random\OSRNG/nt.py 文件中以下代碼:

註釋

import winrandom

新加入

from Crypto.Random.OSRNG import winrandom

暫時沒有解決………………

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章