--- tags: work --- # Win10下安裝pycrypto ## 現況 在使用pyinstaller輸出python專案時會使用到pycrypto套件。官方給的方法是`pip install pycrypto` 可是pycrypto早已不支援現在的python(3.7)並且已經被pycryptodome取代。但是直接安裝pycryptodome可能會造成錯誤。這裡紀載著在win10, python3.7的環境下硬是要裝pycrypto的方法。 ## 開始旅途 ### 美麗的錯誤 在我運行`pip3 install pycrypto`時遇到了以下錯誤 ``` p\pycrypto-2.6.1>python setup.py install running install running build running build_py running build_ext warning: GMP or MPIR library not found; Not building Crypto.PublicKey._fastmath. building 'Crypto.Random.OSRNG.winrandom' extension error: Unable to find vcvarsall.bat ``` ### 搬救兵 [下載Visual C++ Build Tools 2015](https://drive.google.com/a/cnsrl.cycu.edu.tw/file/d/1Y3NA2kOXL2L2VKA2F_K42UAv-Y1GUc02/view?usp=sharing) 1.安裝Windows 10 SDK  2.複製檔案`C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\VC\include\stdint.h` 到`C:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt` 3.修改inttypes.h (路徑為C:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt) 將`#include <stdint.h>` 改成 `#include "stdint.h"`  4.再次安裝pycrypto ``` >pip install pycrypto Collecting pycrypto Using cached https://files.pythonhosted.org/packages/60/db/645aa9af249f059cc3a368b118de33889219e0362141e75d4eaf6f80f163/pycrypto-2.6.1.tar.gz Installing collected packages: pycrypto Running setup.py install for pycrypto ... done Successfully installed pycrypto-2.6.1 ``` **成功!** ## Reference [pycrypto安装报错error:Unable to find vcvarsall.bat](https://www.jianshu.com/p/c540494a4a27)
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up