在Windows 10 x64和Python 3.6.5中安装pycrypto:在C:\ Users \ x \ AppData \ Local \ Temp \ pip-install-u7xhxrk \ pycrypto \中失败,错误代码为1

时间:2018-05-25 04:42:24

标签: python cryptography pycrypto

我需要pycrypto,因为需要使用dnspython库中的某些函数。我在网上发现了一些帖子,表明pycrypto已经死了。但是,我需要dnspython并且别无选择,只能使用它。我甚至尝试安装pycryptodome,因为他们认为它是pycrypto的替代品,但我使用dnspython库的程序引发了错误:

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

根据similar error,使用pycryptodome代替pycrypto。在我的情况下,Pycryptodome不能代替pycrypto。

我安装了Visual Studio 2017.我按照库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

不幸的是,这没有帮助。我甚至尝试从VC命令提示符运行pip install pycrypto但仍然无法安装它。我还在环境变量中添加了以下路径。

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

安装尝试的摘要:

        ----------------------------------------
    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\

有关详细信息,这也在输出中:

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

你能解决问题吗?

1 个答案:

答案 0 :(得分:2)

好的,我遇到了确切的问题,并且可以通过执行以下步骤来解决:

将Visual Studio VC目录添加到用户变量中的环境变量中:

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

请注意,变量应位于用户变量中,而不应位于系统变量中。

打开cmd后,键入以下命令。

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

然后运行pip install

pip install pycrypto