Python-3.6 安装pycrypto 2.6

1.下载pycrypto源码

官网:https://www.dlitz.net/software/pycrypto/ 
github:https://github.com/dlitz/pycrypto 
下载源码解压,win+R运行cmd,进入解压文件夹

python setup.py install
  • 1

如果没有报错误,看到

running install_egg_info
  • 1

恭喜你,不用踩坑,直接可以关闭这篇东西去愉快地写代码了

2.安装过程中显示unable to find vcvarsall.bat

这是window环境下安装模块比较常见的问题,这时候你百度的话大部分文章就会告诉你下载vs,python2的话安装vs2010,python3的话安装vs2013 。

vs的版本号对应关系如下: 

msvs2005版本号为8.0,对应环境变量VS80COMNTOOLS 
msvs2008版本号为9.0,对应环境变量VS90COMNTOOLS 
msvs2010版本号为10.0,对应环境变量VS100COMNTOOLS 
msvs2012版本号为11.0,对应环境变量VS110COMNTOOLS 
msvs2013版本号为12.0,对应环境变量VS120COMNTOOLS 
msvs2015版本号为14.0,对应环境变量VS140COMNTOOLS

3.安装对应版本的msvs(Microsoft Visual Studio)

如果是Visual Studio 2015,提供个百度经验上百度网盘给大家 
http://pan.baidu.com/s/1eSueWLG 
如果不需要用vs进行开发的话,装community免费版就可以了,没必要纠结专业版啥的 
安装过程中要注意,建议安装的时候选自定义(截图来自百度经验,因为已经安装了打开之后有点不太一样) 
这里写图片描述 

  • VC++2015
  • Python Tools
  • Web Deveolper Tools 
    这三个模块,500M左右,重新安装就提示全部成功了 
    很多人说装完之后要改环境变量,
 python2:set VS90COMNTOOLS=%VS140COMNTOOLS%
 python3:set VS100COMNTOOLS=%VS140COMNTOOLS%
  • 1
  • 2

可能python3.6版本高了不需要这样,不过也记录一下给各位看官仅供参考。反正我是不需要改,因为接下来我踩了另一个坑 
再次进入pycryto的解压文件夹python setup.py install 仍然显示 
building ‘Crypto.Random.OSRNG.winrandom‘ extension

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
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\x86_amd64\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -Isrc/ -Isrc/inc-msvc/ -IC:\Python36\include -IC:\Python36\include
winrand.c
C:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt\inttypes.h(26): error C2061: syntax error: identifier ‘intmax_t‘
C:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt\inttypes.h(27): error C2061: syntax error: identifier ‘rem‘
C:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt\inttypes.h(27): error C2059: syntax error: ‘;‘
C:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt\inttypes.h(28): error C2059: syntax error: ‘}‘
C:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt\inttypes.h(30): error C2061: syntax error: identifier ‘imaxdiv_t‘
C:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt\inttypes.h(30): error C2059: syntax error: ‘;‘
C:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt\inttypes.h(40): error C2143: syntax error: missing ‘{‘ before ‘__cdecl‘
C:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt\inttypes.h(41): error C2146: syntax error: missing ‘)‘ before identifier ‘_Number‘
C:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt\inttypes.h(41): error C2061: syntax error: identifier ‘_Number‘
C:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt\inttypes.h(41): error C2059: syntax error: ‘;‘
C:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt\inttypes.h(42): error C2059: syntax error: ‘)‘
C:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt\inttypes.h(45): error C2143: syntax error: missing ‘{‘ before ‘__cdecl‘
C:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt\inttypes.h(46): error C2146: syntax error: missing ‘)‘ before identifier ‘_Numerator‘
C:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt\inttypes.h(46): error C2061: syntax error: identifier ‘_Numerator‘
C:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt\inttypes.h(46): error C2059: syntax error: ‘;‘
C:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt\inttypes.h(46): error C2059: syntax error: ‘,‘
C:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt\inttypes.h(48): error C2059: syntax error: ‘)‘
C:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt\inttypes.h(50): error C2143: syntax error: missing ‘{‘ before ‘__cdecl‘
C:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt\inttypes.h(56): error C2143: syntax error: missing ‘{‘ before ‘__cdecl‘
C:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt\inttypes.h(63): error C2143: syntax error: missing ‘{‘ before ‘__cdecl‘
C:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt\inttypes.h(69): error C2143: syntax error: missing ‘{‘ before ‘__cdecl‘
C:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt\inttypes.h(76): error C2143: syntax error: missing ‘{‘ before ‘__cdecl‘
C:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt\inttypes.h(82): error C2143: syntax error: missing ‘{‘ before ‘__cdecl‘
C:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt\inttypes.h(89): error C2143: syntax error: missing ‘{‘ before ‘__cdecl‘
C:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt\inttypes.h(95): error C2143: syntax error: missing ‘{‘ before ‘__cdecl‘
error: command ‘C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\BIN\\x86_amd64\\cl.exe‘ failed with exit status 2
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34

4.解决building ‘Crypto.Random.OSRNG.winrandom‘ extension

1.添加VC环境变量,设置用户环境变量,这里划重点!!!是用户环境变量,不是系统环境变量 
这里写图片描述 
变量名:VCINSTALLDIR 
(变量值为vs安装路径下的VC,默认是这个) 
变量值:C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC 
2. win+R运行cmd,执行命令set CL=/FI”%VCINSTALLDIR%\INCLUDE\stdint.h” %CL% 
3. 再次进入pycryto的解压文件夹python setup.py install ,看到这里写图片描述 

能显示running install_egg_info 就是安装成功了

如果不行的话,可以右键以管理员运行。

原文转自:https://blog.csdn.net/a624806998/article/details/78596543

阅读更多
文章标签: python pycrypto
个人分类: Python
想对作者说点什么? 我来说一句

没有更多推荐了,返回首页

关闭
关闭
关闭