简体   繁体   中英

Installing pycrypto in Windows 10 x64 and Python 3.6.5: failed with error code 1 in C:\Users\x\AppData\Local\Temp\pip-install-u7xhxrk \pycrypto\

I need pycrypto as it is required to use some functions with dnspython library. I found some posts online suggesting that pycrypto is dead. However, I need dnspython and has no choice but to use it. I even tried to install pycryptodome as they suggest it is a replacement for pycrypto but my program which uses dnspython library raised an error:

Traceback (most recent call last):
  File "test-3-dnssec.py", line 40, in <module>
    dns.dnssec.validate(answer[0],answer[1],{name:answer[0]})
  File "C:\Python36\lib\site-packages\dns\dnssec.py", line 417, in _validate
    _validate_rrsig(rrset, rrsig, keys, origin, now)
  File "C:\Python36\lib\site-packages\dns\dnssec.py", line 371, in _validate_rrsig
    if pubkey.verify(digest, sig):
  File "C:\Python36\lib\site-packages\Crypto\PublicKey\RSA.py", line 372, in verify
    raise NotImplementedError("Use module Crypto.Signature.pkcs1_15 instead")
NotImplementedError: Use module Crypto.Signature.pkcs1_15 instead

which according to similar error , is becuase using pycryptodome instead of pycrypto . Pycryptodome is not a replacement for pycrypto in my case.

I installed Visual Studio 2017. I did these steps as suggested in the library's gihub page :

cd "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build"
vcvarsall amd64
cd \
set CL=-FI"%VCINSTALLDIR%\tools\msvc\14.13.26128\include\stdint.h"

pip install pycrypto

Unfortunately, this did not help. I even tried to run pip install pycrypto from the VC command prompt but still can't get it installed. I also added the following path to the environmental variables.

C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build

The summary of the installation attempt:

        ----------------------------------------
    Command "c:\python36\python.exe -u -c "import setuptools,
tokenize;__file__='C:\\Users\\xx\\AppData\\Local\\Temp\\pip-install-u7xhxrk
\\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\e\AppData\Local\Temp\pip-record
a7yh6xa5\install-record.txt --single-version-externally-managed --compile"
failed with error code 1 in C:\Users\e\AppData\Local\Temp\pip-install-u7xhxrk
\pycrypto\

For more details this is also in the output:

C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.14.26428\bin\HostX86\x64\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -Isrc/ -Isrc/inc-msvc/ -Ic:\python36\include -Ic:\python36\include "-IC:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.14.26428\ATLMFC\include" "-IC:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.14.26428\include" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17134.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17134.0\shared" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17134.0\um" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17134.0\winrt" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17134.0\cppwinrt" /Tcsrc/winrand.c /Fobuild\temp.win-amd64-3.6\Release\src/winrand.obj
winrand.c
C:\Program Files (x86)\Windows Kits\10\include\10.0.17134.0\ucrt\inttypes.h(27): error C2061: syntax error: identifier 'intmax_t'
C:\Program Files (x86)\Windows Kits\10\include\10.0.17134.0\ucrt\inttypes.h(28): error C2061: syntax error: identifier 'rem'
C:\Program Files (x86)\Windows Kits\10\include\10.0.17134.0\ucrt\inttypes.h(28): error C2059: syntax error: ';'
C:\Program Files (x86)\Windows Kits\10\include\10.0.17134.0\ucrt\inttypes.h(29): error C2059: syntax error: '}'
C:\Program Files (x86)\Windows Kits\10\include\10.0.17134.0\ucrt\inttypes.h(31): error C2061: syntax error: identifier 'imaxdiv_t'
C:\Program Files (x86)\Windows Kits\10\include\10.0.17134.0\ucrt\inttypes.h(31): error C2059: syntax error: ';'
C:\Program Files (x86)\Windows Kits\10\include\10.0.17134.0\ucrt\inttypes.h(41): error C2143: syntax error: missing '{' before '__cdecl'
C:\Program Files (x86)\Windows Kits\10\include\10.0.17134.0\ucrt\inttypes.h(42): error C2146: syntax error: missing ')' before identifier '_Number'
C:\Program Files (x86)\Windows Kits\10\include\10.0.17134.0\ucrt\inttypes.h(42): error C2061: syntax error: identifier '_Number'
C:\Program Files (x86)\Windows Kits\10\include\10.0.17134.0\ucrt\inttypes.h(42): error C2059: syntax error: ';'
C:\Program Files (x86)\Windows Kits\10\include\10.0.17134.0\ucrt\inttypes.h(43): error C2059: syntax error: ')'
C:\Program Files (x86)\Windows Kits\10\include\10.0.17134.0\ucrt\inttypes.h(46): error C2143: syntax error: missing '{' before '__cdecl'
C:\Program Files (x86)\Windows Kits\10\include\10.0.17134.0\ucrt\inttypes.h(47): error C2146: syntax error: missing ')' before identifier '_Numerator'
C:\Program Files (x86)\Windows Kits\10\include\10.0.17134.0\ucrt\inttypes.h(47): error C2061: syntax error: identifier '_Numerator'
C:\Program Files (x86)\Windows Kits\10\include\10.0.17134.0\ucrt\inttypes.h(47): error C2059: syntax error: ';'
C:\Program Files (x86)\Windows Kits\10\include\10.0.17134.0\ucrt\inttypes.h(47): error C2059: syntax error: ','
C:\Program Files (x86)\Windows Kits\10\include\10.0.17134.0\ucrt\inttypes.h(49): error C2059: syntax error: ')'
C:\Program Files (x86)\Windows Kits\10\include\10.0.17134.0\ucrt\inttypes.h(51): error C2143: syntax error: missing '{' before '__cdecl'
C:\Program Files (x86)\Windows Kits\10\include\10.0.17134.0\ucrt\inttypes.h(57): error C2143: syntax error: missing '{' before '__cdecl'
C:\Program Files (x86)\Windows Kits\10\include\10.0.17134.0\ucrt\inttypes.h(64): error C2143: syntax error: missing '{' before '__cdecl'
C:\Program Files (x86)\Windows Kits\10\include\10.0.17134.0\ucrt\inttypes.h(70): error C2143: syntax error: missing '{' before '__cdecl'
C:\Program Files (x86)\Windows Kits\10\include\10.0.17134.0\ucrt\inttypes.h(77): error C2143: syntax error: missing '{' before '__cdecl'
C:\Program Files (x86)\Windows Kits\10\include\10.0.17134.0\ucrt\inttypes.h(83): error C2143: syntax error: missing '{' before '__cdecl'
C:\Program Files (x86)\Windows Kits\10\include\10.0.17134.0\ucrt\inttypes.h(90): error C2143: syntax error: missing '{' before '__cdecl'
C:\Program Files (x86)\Windows Kits\10\include\10.0.17134.0\ucrt\inttypes.h(96): error C2143: syntax error: missing '{' before '__cdecl'
error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\Community\\VC\\Tools\\MSVC\\14.14.26428\\bin\\HostX86\\x64\\cl.exe' failed with exit status 2

Can you figure out the problem?

Okay, I was experiencing the exact problem and have been able to resolve by doing the following steps:

Add the Visual Studio VC directory to the environment variables, in the User variables:

Variable Name: VCINSTALLDIR
Variable Value: C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC

Note that the variables should be in User variables not in the system variables.

After opening cmd, type the following command.

set CL=/FI"%VCINSTALLDIR%\INCLUDE\stdint.h" %CL%

Then run the pip install

pip install pycrypto

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM