pycrypto installation errors

Recent contact with the development company back office management system, which involves encryption module pycrypto.
Focus here! ! ! ! Knock blackboard! ! ! !
pycrypto in PyCharm in with the other modules are not the same, pip install pycrypto installed the 1.4.1 version, and then be able to install the module, although successful, but in fact the code still can not associate running anomalies will be reported.
Baidu Solution: Download pycrypto source installation
but install pycrypto source is not such a simple thing, here these days stepped pits are recorded it.

1. Download Source pycrypto
official website: HTTPS: //www.dlitz.net/software/pycrypto/
GitHub: HTTPS: //github.com/dlitz/pycrypto
download the source code decompression, win + R to run cmd, extract the folder into the

setup.py install Python
1
If there are no reported errors, see

install_egg_info running
1
Congratulations, do not step on the pit, you can turn off this stuff directly to the happily write code

Display unable to find vcvarsall.bat 2. Setup
This is the window environment module installed relatively common problem, this time, then you Baidu Most of the articles will tell you to download vs, python2 then install vs2010, python3 then install vs2013
focus! ! ! ! ! ! ! !
Do not rush to install vs, which is a good thing to install a few hours, where I installed vs unloading, loading unloading waste a day and a half.
python has a pit! Different versions of python vs corresponding to different versions, in particular the corresponding versions of python path where \ Lib \ distutils_msvccompiler.py
example, my path is E: \ Python \ Python36 \ Lib \ distutils_msvccompiler.py
open to find def _find_vcvarsall (plat_spec)
this function has one if version> = 14 and version> best_version


Where version> = 14 is the corresponding vs version number, if you're like me, then it should be python3.6 here is 14, is seen before other blog, view the version number is not here pretend, first installed vs2010, then loaded 2013, then unloading installed vs2015 corresponding version number, version number of the corresponding relationship vs follows:
msvs2005 version number is 8.0, the corresponding environment variable VS80COMNTOOLS
msvs2008 version number is 9.0, the corresponding environment variable VS90COMNTOOLS
msvs2010 version 10.0, corresponding to the environment variable VS100COMNTOOLS
msvs2012 version number is 11.0, the corresponding environment variable VS110COMNTOOLS
msvs2013 version number is 12.0, the corresponding environment variable VS120COMNTOOLS
msvs2015 version number is 14.0, the corresponding environment variables VS140COMNTOOLS

3. Install the corresponding version of msvs (Microsoft Visual Studio)
If Visual Studio 2015, providing a network disk on Baidu Baidu experience for everyone
http://pan.baidu.com/s/1eSueWLG
If you do not develop with vs then, free community version installed on it, no need to tangle Pro Han
installation process should pay attention, recommended the installation of the selected custom (Screenshot from Baidu experience, as it has been installed after opening a bit different)

Remember to check the VC ++ 2015 and Python Tools. Web Deveolper Tools, then at best hook on it.
But I did not so smooth installation process, tears ran ~

Install some modules fail, then I re-install. Because the main vs2015 installation is successful, so just check

++ 2015 VC
Python Tools
Web Tools Deveolper
three modules, about 500M, you are prompted to reinstall all the success
a lot of people say that after Bahrain to change environment variables,
 python2: the SET VS90COMNTOOLS =% VS140COMNTOOLS%
 python3: the SET VS100COMNTOOLS =% VS140COMNTOOLS %
1
2
may python3.6 version does not require such a high, but also to record what you Tell me are for reference only. Anyway, I do not need to change, because then I stepped on another pit
into the pycryto unzipped folders again python setup.py install still show
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: the Command 'C: \\ Program Files (x86) \\ in the Microsoft Visual Studio VC 14.0 \\ \\ \\ BIN \\ x86_amd64 cl.exe' failed The Status 2 with Exit

4. solve building 'Crypto.Random.OSRNG. winrandom 'Extension
1. Add the VC environment variables, set user environment variables, draw the focus here! ! ! It is a user environment variable, not the system environment variables

Variable name: VCInstallDir
(variable value vs VC in the installation path, this is the default)
variable value: C: \ Program Files (x86) \ in the Microsoft Visual Studio 14.0 \ VC
2. win + R to run cmd, execute the command set CL = /FI"%VCINSTALLDIR%\INCLUDE\stdint.h "% CL%
3. re-enter pycryto extract the folder python setup.py install, see
to show that the installation was successful running install_egg_info

5. Note that Crypto or crypto, case-sensitive
codes alt + enter automatic association after successful installation I was here

AES crypto.Cipher import from
. 1
and then run the code given point inside the import into the AES

Import _AES Crypto.Cipher from
1
junior partner with me if you encounter the same problem, you can manually enter python \ under Lib, my path is
E: \ Python \ Python36 \ Lib
then put into a folder crypto Crypto. The lowercase into uppercase, refresh, perfect run ~ ~ ~ ~

Published 14 original articles · won praise 0 · Views 204

Guess you like

Origin blog.csdn.net/qq_36283674/article/details/103285689
Recommended