Error in Windows7 Python-3.6 installation PyCrypto (pycrypto 2.6.1) and its solution
Today, I'm going to install a pycrypto 2.6.1 module based on python3.6 on the Windows system, and unfortunately I reported a bunch of errors, as follows:
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
After a period of Baidu and Google and an attempt to install pycrypto 2.6.1 successfully, the specific solutions are as follows:
Set the environment variable for Microsoft Visual Studio 14.0, as shown in the figure:
Open cmd and execute the following command: set CL=/FI "% VCINSTALLDIR%\\ INCLUDE\\ stdint.h"% CL%
Reinstall pycrypto 2.6.1
Enter the pycrypto 2.6.1 directory through cmd and execute python setup.py install
The results are as follows:
Pycrypto 2.6.1 was successfully installed.