PyCrypto installation error (vc\cl.exe fails no matter what)

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-06 08:39:46

问题


I am trying to install pyCrypto (by pip3 install pycrypto) , and I keep getting this error :

  Failed building wheel for pycrypto
  Running setup.py clean for pycrypto
Failed to build pycrypto
Installing collected packages: pycrypto
  Running setup.py install for pycrypto ... error
    Complete output from command c:\users\1007238\appdata\local\programs\python\python36-32\python.exe -u -c "import setuptools, tokenize;__file__='C:\\Users\\1007238\\AppData\\Local\\Temp\\pip-build-pm8w3iz2\\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\1007238\AppData\Local\Temp\pip-rd551f7l-record\install-record.txt --single-version-externally-managed --compile:
    running install
    running build
    running build_py
    creating build
    creating build\lib.win32-3.6
    creating build\lib.win32-3.6\Crypto
    copying lib\Crypto\pct_warnings.py -> build\lib.win32-3.6\Crypto

Installation goes well until :

    C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -Isrc/ -Isrc/inc-msvc/ -Ic:\users\1007238\appdata\local\programs\python\python36-32\include -Ic:\users\1007238\appdata\local\programs\python\python36-32\include "-IC:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\INCLUDE" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.15063.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\NETFXSDK\4.6.1\include\um" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.15063.0\shared" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.15063.0\um" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.15063.0\winrt" -IC:\OpenSSL-1.0.1f-64bit\include "-IC:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\INCLUDE" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.15063.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\NETFXSDK\4.6.1\include\um" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.15063.0\shared" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.15063.0\um" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.15063.0\winrt" /Tcsrc/winrand.c /Fobuild\temp.win32-3.6\Release\src/winrand.obj
    winrand.c
    C:\Program Files (x86)\Windows Kits\10\include\10.0.15063.0\ucrt\inttypes.h(26): error C2061: syntax error: identifier 'intmax_t'
    C:\Program Files (x86)\Windows Kits\10\include\10.0.15063.0\ucrt\inttypes.h(27): error C2061: syntax error: identifier 'rem'
    C:\Program Files (x86)\Windows Kits\10\include\10.0.15063.0\ucrt\inttypes.h(27): error C2059: syntax error: ';'
    C:\Program Files (x86)\Windows Kits\10\include\10.0.15063.0\ucrt\inttypes.h(28): error C2059: syntax error: '}'
    C:\Program Files (x86)\Windows Kits\10\include\10.0.15063.0\ucrt\inttypes.h(30): error C2061: syntax error: identifier 'imaxdiv_t'
    C:\Program Files (x86)\Windows Kits\10\include\10.0.15063.0\ucrt\inttypes.h(30): error C2059: syntax error: ';'
    C:\Program Files (x86)\Windows Kits\10\include\10.0.15063.0\ucrt\inttypes.h(40): error C2143: syntax error: missing '{' before '__cdecl'
    C:\Program Files (x86)\Windows Kits\10\include\10.0.15063.0\ucrt\inttypes.h(41): error C2146: syntax error: missing ')' before identifier '_Number'
    C:\Program Files (x86)\Windows Kits\10\include\10.0.15063.0\ucrt\inttypes.h(41): error C2061: syntax error: identifier '_Number'
    C:\Program Files (x86)\Windows Kits\10\include\10.0.15063.0\ucrt\inttypes.h(41): error C2059: syntax error: ';'
    C:\Program Files (x86)\Windows Kits\10\include\10.0.15063.0\ucrt\inttypes.h(42): error C2059: syntax error: ')'
    C:\Program Files (x86)\Windows Kits\10\include\10.0.15063.0\ucrt\inttypes.h(45): error C2143: syntax error: missing '{' before '__cdecl'
    C:\Program Files (x86)\Windows Kits\10\include\10.0.15063.0\ucrt\inttypes.h(46): error C2146: syntax error: missing ')' before identifier '_Numerator'
    C:\Program Files (x86)\Windows Kits\10\include\10.0.15063.0\ucrt\inttypes.h(46): error C2061: syntax error: identifier '_Numerator'
    C:\Program Files (x86)\Windows Kits\10\include\10.0.15063.0\ucrt\inttypes.h(46): error C2059: syntax error: ';'
    C:\Program Files (x86)\Windows Kits\10\include\10.0.15063.0\ucrt\inttypes.h(46): error C2059: syntax error: ','
    C:\Program Files (x86)\Windows Kits\10\include\10.0.15063.0\ucrt\inttypes.h(48): error C2059: syntax error: ')'
    C:\Program Files (x86)\Windows Kits\10\include\10.0.15063.0\ucrt\inttypes.h(50): error C2143: syntax error: missing '{' before '__cdecl'
    C:\Program Files (x86)\Windows Kits\10\include\10.0.15063.0\ucrt\inttypes.h(56): error C2143: syntax error: missing '{' before '__cdecl'
    C:\Program Files (x86)\Windows Kits\10\include\10.0.15063.0\ucrt\inttypes.h(63): error C2143: syntax error: missing '{' before '__cdecl'
    C:\Program Files (x86)\Windows Kits\10\include\10.0.15063.0\ucrt\inttypes.h(69): error C2143: syntax error: missing '{' before '__cdecl'
    C:\Program Files (x86)\Windows Kits\10\include\10.0.15063.0\ucrt\inttypes.h(76): error C2143: syntax error: missing '{' before '__cdecl'
    C:\Program Files (x86)\Windows Kits\10\include\10.0.15063.0\ucrt\inttypes.h(82): error C2143: syntax error: missing '{' before '__cdecl'
    C:\Program Files (x86)\Windows Kits\10\include\10.0.15063.0\ucrt\inttypes.h(89): error C2143: syntax error: missing '{' before '__cdecl'
    C:\Program Files (x86)\Windows Kits\10\include\10.0.15063.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\\cl.exe' failed with exit status 2

I have searched every topic I could find regarding this exact error , both on this website and many other , but I could not find a fitting solution. (please , don't link me existing threads from this website)

Some things worth mentioning : I have tried setting up the env. variables , it didn't help.

I have also tried running vcvarsall.bat (inside VC) , as many have suggested. No effect.

Finally , I have tried reinstalling visual studio. 0 effect as well.

Any ideas ?


回答1:


I found the solution : After following the advice of Dave (from comments), I encountered a new error , which I then solved by following this thread Python, installing clarifai --> VS14.0 link.exe failed with exit status 1158




回答2:


This is the solution provided in this blog post

Edit the file inttypes.h and add just before the line of the error:

#define intmax_t long long
#define uintmax_t unsigned long long

Also, the solution provided in this StackOverflow question by @user1602 seems better, since it doesn't involve changing files in Windows SDK:

A workaround for Microsoft VC compiler is to force include stdint.h via OS environment variable CL:

  1. Open command prompt
  2. Setup VC environment by runing vcvars*.bat (choose file name depending on VC version and architecture)
  3. set CL=-FI"Full-Path\stdint.h" (use real value for Full-Path for the environment)
  4. pip install pycrypto


来源:https://stackoverflow.com/questions/45032787/pycrypto-installation-error-vc-cl-exe-fails-no-matter-what

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!