在测试一个python操作AES加密解密的脚本时,发现需要安装一些依赖package,大部分直接pip install就搞定了,结果到pycrypto的时候,却遇到了pip报错安装失败的问题,仔细看了下发现是编译出错,搜索了下找到了这个:https://github.com/dlitz/pycrypto/issues/218,原来是需要VS Build Tools环境的问题,按照最后的提示(指定32位编译环境):
for Python 3.6 32 bit following set of commands worked:
cd “C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build”
vcvarsall.bat x86_amd64
cd \
set CL=-FI”%VCINSTALLDIR%\tools\msvc\14.14.26428\include\stdint.h”
pip install pycrypto
执行后,提示:
winrand.c
src/winrand.c: fatal error C1083: Cannot open include file: ‘D:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\\tools\msvc\14.14.26428\include\stdint.h’: No such file or directory
error: command ‘D:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\Community\\VC\\Tools\\MSVC\\14.13.26128\\bin\\HostX86\\x86\\cl.exe’ failed with exit status 2—————————————-
Command “d:\python\python36-32\python.exe -u -c “import setuptools, tokenize;__file__=’C:\\Users\\wzkres\\AppData\\Local\\Temp\\pip-build-ls0az06a\\pycrypto\\setup.py’;f=getattr(tokenize, ‘open’, open)(__file__);code=f.read().replace(‘\r\n’, ‘\n’);f.close();exec(compile(code, __file__, ‘exec’))” install –record C:\Users\wzkres\AppData\Local\Temp\pip-t3k_i9q1-record\install-record.txt –single-version-externally-managed –compile” failed with error code 1 in C:\Users\wwwuser\AppData\Local\Temp\pip-build-ls0az06a\pycrypto\
stdint.h没找到,进自己这边的tools\msvc路径一看,原来是版本号略有不同,修改为本地正确的路径:
D:\>set CL=-FI”%VCINSTALLDIR%\tools\msvc\14.13.26128\include\stdint.h”
然后再次pip install…就ok了:
D:\>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
博主友情提示:
如您在评论中需要提及如QQ号、电子邮件地址或其他隐私敏感信息,欢迎使用>>博主专用加密工具v3<<处理后发布,原文只有博主可以看到。