windows 安装 pycrypto,报错如下:

C:UsersAdministrator>pip install  pycrypto
Collecting pycrypto
  Using cached https://files.pythonhosted.org/packages/60/db/645aa9af249f059cc3a368b118de33889219e0362141e75d4eaf6f80f163/pycrypto-2.6.1.tar.gz
Installing collected packages: pycrypto
  Running setup.py install for pycrypto ... error
    Complete output from command c:usersadministratorappdatalocalprogramspythonpython37python.exe -u -c "import setuptools, tokenize;__file__='C:\Users\ADMINI~1\AppData\Local\Temp\pip-install-ulesvgto\pycrypto\setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('rn', 'n');f.close();exec(compile(code, __file__, 'exec'))" install --record C:UsersADMINI~1AppDataLocalTemppip-record-hzl0jck4install-record.txt --single-version-externally-managed --compile:
    running install
    running build
    running build_py
    creating build
    creating buildlib.win-amd64-3.7
    creating buildlib.win-amd64-3.7Crypto
    copying libCryptopct_warnings.py -> buildlib.win-amd64-3.7Crypto
    copying libCrypto__init__.py -> buildlib.win-amd64-3.7Crypto
    creating buildlib.win-amd64-3.7CryptoHash
    copying libCryptoHashhashalgo.py -> buildlib.win-amd64-3.7CryptoHash
    copying libCryptoHashHMAC.py -> buildlib.win-amd64-3.7CryptoHash
    copying libCryptoHashMD2.py -> buildlib.win-amd64-3.7CryptoHash
     ....省略部分输出信息
    creating buildlib.win-amd64-3.7CryptoSignature
    copying libCryptoSignaturePKCS1_PSS.py -> buildlib.win-amd64-3.7CryptoSignature
    copying libCryptoSignaturePKCS1_v1_5.py -> buildlib.win-amd64-3.7CryptoSignature
    copying libCryptoSignature__init__.py -> buildlib.win-amd64-3.7CryptoSignature
    Skipping optional fixer: buffer
    Skipping optional fixer: idioms
    Skipping optional fixer: set_literal
    Skipping optional fixer: ws_comma
    running build_ext
    warning: GMP or MPIR library not found; Not building Crypto.PublicKey._fastmath.
    building 'Crypto.Random.OSRNG.winrandom' extension
    error: Microsoft Visual C++ 14.0 is required. Get it with "Microsoft Visual C++ Build Tools": https://visualstudio.microsoft.com/downloads/

    ----------------------------------------
Command "c:usersadministratorappdatalocalprogramspythonpython37python.exe -u -c "import setuptools, tokenize;__file__='C:\Users\ADMINI~1\AppData\Local\Temp\pip-install-ulesvgto\pycrypto\setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('rn', 'n');f.close();exec(compile(code, __file__, 'exec'))" install --record C:UsersADMINI~1AppDataLocalTemppip-record-hzl0jck4install-record.txt --single-version-externally-managed --compile" failed with error code 1 in C:UsersADMINI~1AppDataLocalTemppip-install-ulesvgtopycrypto

error: Microsoft Visual C++ 14.0 is required,缺少 Microsoft Visual C++ 14.0 ,安装。
下载链接:https://pan.baidu.com/s/1V8ec8VnOFZ_xRb_vwQuspA
提取码:uhvh
安装完成之后继续。

C:UsersAdministrator>pip install  pycrypto
Collecting pycrypto
  Using cached https://files.pythonhosted.org/packages/60/db/645aa9af249f059cc3a368b118de33889219e0362141e75d4eaf6f80f163/pycrypto-2.6.1.tar.gz
Installing collected packages: pycrypto
  Running setup.py install for pycrypto ... error
    Complete output from command c:usersadministratorappdatalocalprogramspythonpython37python.exe -u -c "import setuptools, tokenize;__file__='C:\Users\ADMINI~1\AppData\Local\Temp\pip-install-hixqa5cf\pycrypto\setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('rn', 'n');f.close();exec(compile(code, __file__, 'exec'))" install --record C:UsersADMINI~1AppDataLocalTemppip-record-jdpzups3install-record.txt --single-version-externally-managed --compile:
    running install
    running build
    running build_py
    creating build
    creating buildlib.win-amd64-3.7
    creating buildlib.win-amd64-3.7Crypto
    copying libCryptopct_warnings.py -> buildlib.win-amd64-3.7Crypto
    copying libCrypto__init__.py -> buildlib.win-amd64-3.7Crypto
    ....省略部分输出信息
    copying libCryptoSignature__init__.py -> buildlib.win-amd64-3.7CryptoSignature
    Skipping optional fixer: buffer
    Skipping optional fixer: idioms
    Skipping optional fixer: set_literal
    Skipping optional fixer: ws_comma
    running build_ext
    warning: GMP or MPIR library not found; Not building Crypto.PublicKey._fastmath.
    building 'Crypto.Random.OSRNG.winrandom' extension
    creating buildtemp.win-amd64-3.7
    creating buildtemp.win-amd64-3.7Release
    creating buildtemp.win-amd64-3.7Releasesrc
    C:Program Files (x86)Microsoft Visual Studio 14.0VCBINx86_amd64cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -Isrc/ -Isrc/inc-msvc/ -Ic:usersadministratorappdatalocalprogramspythonpython37include -Ic:usersadministratorappdatalocalprogramspythonpython37include "-IC:Program Files (x86)Microsoft Visual Studio 14.0VCINCLUDE" "-IC:Program Files (x86)Windows Kits10include10.0.10240.0ucrt" "-IC:Program Files (x86)Windows Kits8.1includeshared" "-IC:Program Files (x86)Windows Kits8.1includeum" "-IC:Program Files (x86)Windows Kits8.1includewinrt" /Tcsrc/winrand.c /Fobuildtemp.win-amd64-3.7Releasesrc/winrand.obj
    winrand.c
    C:Program Files (x86)Windows Kits10include10.0.10240.0ucrtinttypes.h(26): error C2061: syntax error: identifier 'intmax_t'
    ....省略部分输出信息
    C:Program Files (x86)Windows Kits10include10.0.10240.0ucrtinttypes.h(69): error C2143: syntax error: missing '{' before '__cdecl'
    C:Program Files (x86)Windows Kits10include10.0.10240.0ucrtinttypes.h(76): error C2143: syntax error: missing '{' before '__cdecl'
    C:Program Files (x86)Windows Kits10include10.0.10240.0ucrtinttypes.h(82): error C2143: syntax error: missing '{' before '__cdecl'
    C:Program Files (x86)Windows Kits10include10.0.10240.0ucrtinttypes.h(89): error C2143: syntax error: missing '{' before '__cdecl'
    C:Program Files (x86)Windows Kits10include10.0.10240.0ucrtinttypes.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

    ----------------------------------------
Command "c:usersadministratorappdatalocalprogramspythonpython37python.exe -u -c "import setuptools, tokenize;__file__='C:\Users\ADMINI~1\AppData\Local\Temp\pip-install-hixqa5cf\pycrypto\setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('rn', 'n');f.close();exec(compile(code, __file__, 'exec'))" install --record C:UsersADMINI~1AppDataLocalTemppip-record-jdpzups3install-record.txt --single-version-externally-managed --compile" failed with error code 1 in C:UsersADMINI~1AppDataLocalTemppip-install-hixqa5cfpycrypto

error: command ‘C:Program Files (x86)Microsoft Visual Studio 14.0VCBINx86_amd64cl.exe’ failed with exit status 2

尝试下载pycrypto的安装包安装, https://www.dlitz.net/software/pycrypto/ 依旧失败。
百度良久,最终通过设置环境变量解决.

找到Microsoft Visual Studio下的stdint.h,set环境变量,再执行 pip install pycrypto 安装即可。

C:UsersAdministrator>set CL=/FI"C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\stdint.h"

C:UsersAdministrator>pip install pycrypto
Defaulting to user installation because normal site-packages is not writeable
Collecting pycrypto
  Using cached pycrypto-2.6.1.tar.gz (446 kB)
Using legacy 'setup.py install' for pycrypto, since package 'wheel' is not installed.
Installing collected packages: pycrypto
    Running setup.py install for pycrypto ... done
Successfully installed pycrypto-2.6.1

若仍失败,可尝试安装包安装。

C:UsersAdministrator>cd Desktoppycrypto-2.6.1pycrypto-2.6.1
C:UsersAdministratorDesktoppycrypto-2.6.1pycrypto-2.6.1>set CL=/FI"C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\stdint.h"

C:UsersAdministratorDesktoppycrypto-2.6.1pycrypto-2.6.1>python setup.py install
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.0VCBINx86_amd64cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -Isrc/ -Isrc/inc-msvc/ -IC:UsersAdministratorAppDataLocalProgramsPythonPython37include -IC:UsersAdministratorAppDataLocalProgramsPythonPython37include "-IC:Program Files (x86)Microsoft Visual Studio 14.0VCINCLUDE" "-IC:Program Files (x86)Windows Kits10include10.0.10240.0ucrt" "-IC:Program Files (x86)Windows Kits8.1includeshared" "-IC:Program Files (x86)Windows Kits8.1includeum" "-IC:Program Files (x86)Windows Kits8.1includewinrt" /Tcsrc/winrand.c /Fobuildtemp.win-amd64-3.7Releasesrc/winrand.obj
winrand.c
C:Program Files (x86)Microsoft Visual Studio 14.0VCBINx86_amd64link.exe /nologo /INCREMENTAL:NO /LTCG /DLL /MANIFEST:EMBED,ID=2 /MANIFESTUAC:NO /LIBPATH:C:UsersAdministratorAppDataLocalProgramsPythonPython37libs /LIBPATH:C:UsersAdministratorAppDataLocalProgramsPythonPython37PCbuildamd64 "/LIBPATH:C:Program Files (x86)Microsoft Visual Studio 14.0VCLIBamd64" "/LIBPATH:C:Program Files (x86)Windows Kits10lib10.0.10240.0ucrtx64" "/LIBPATH:C:Program Files (x86)Windows Kits8.1libwinv6.3umx64" ws2_32.lib advapi32.lib /EXPORT:PyInit_winrandom buildtemp.win-amd64-3.7Releasesrc/winrand.obj /OUT:buildlib.win-amd64-3.7CryptoRandomOSRNGwinrandom.cp37-win_amd64.pyd /IMPLIB:buildtemp.win-amd64-3.7Releasesrcwinrandom.cp37-win_amd64.lib
winrand.obj : warning LNK4197: export 'PyInit_winrandom' specified multiple times; using first specification
   Creating library buildtemp.win-amd64-3.7Releasesrcwinrandom.cp37-win_amd64.lib and object buildtemp.win-amd64-3.7Releasesrcwinrandom.cp37-win_amd64.exp
Generating code
Finished generating code
building 'Crypto.Hash._MD2' extension
C:Program Files (x86)Microsoft Visual Studio 14.0VCBINx86_amd64cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -Isrc/ -Isrc/inc-msvc/ -IC:UsersAdministratorAppDataLocalProgramsPythonPython37include -IC:UsersAdministratorAppDataLocalProgramsPythonPython37include "-IC:Program Files (x86)Microsoft Visual Studio 14.0VCINCLUDE" "-IC:Program Files (x86)Windows Kits10include10.0.10240.0ucrt" "-IC:Program Files (x86)Windows Kits8.1includeshared" "-IC:Program Files (x86)Windows Kits8.1includeum" "-IC:Program Files (x86)Windows Kits8.1includewinrt" /Tcsrc/MD2.c /Fobuildtemp.win-amd64-3.7Releasesrc/MD2.obj
MD2.c
src/MD2.c(101): warning C4018: ' C:UsersAdministratorAppDataLocalProgramsPythonPython37Libsite-packagesCryptoCipher
....省略部分输出信息
copying buildlib.win-amd64-3.7CryptoUtilRFC1751.py -> C:UsersAdministratorAppDataLocalProgramsPythonPython37Libsite-packagesCryptoUtil
copying buildlib.win-amd64-3.7CryptoUtilstrxor.cp37-win_amd64.pyd -> C:UsersAdministratorAppDataLocalProgramsPythonPython37Libsite-packagesCryptoUtil
copying buildlib.win-amd64-3.7CryptoUtilwinrandom.py -> C:UsersAdministratorAppDataLocalProgramsPythonPython37Libsite-packagesCryptoUtil
copying buildlib.win-amd64-3.7CryptoUtil_counter.cp37-win_amd64.pyd -> C:UsersAdministratorAppDataLocalProgramsPythonPython37Libsite-packagesCryptoUtil
copying buildlib.win-amd64-3.7CryptoUtil_number_new.py -> C:UsersAdministratorAppDataLocalProgramsPythonPython37Libsite-packagesCryptoUtil
copying buildlib.win-amd64-3.7CryptoUtil__init__.py -> C:UsersAdministratorAppDataLocalProgramsPythonPython37Libsite-packagesCryptoUtil
copying buildlib.win-amd64-3.7Crypto__init__.py -> C:UsersAdministratorAppDataLocalProgramsPythonPython37Libsite-packagesCrypto
byte-compiling C:UsersAdministratorAppDataLocalProgramsPythonPython37Libsite-packagesCryptoCipherAES.py to AES.cpython-37.pyc
byte-compiling C:UsersAdministratorAppDataLocalProgramsPythonPython37Libsite-packagesCryptoCipherARC2.py to ARC2.cpython-37.pyc
byte-compiling C:UsersAdministratorAppDataLocalProgramsPythonPython37Libsite-packagesCryptoCipherARC4.py to ARC4.cpython-37.pyc
byte-compiling C:UsersAdministratorAppDataLocalProgramsPythonPython37Libsite-packagesCryptoCipherblockalgo.py to blockalgo.cpython-37.pyc
byte-compiling C:UsersAdministratorAppDataLocalProgramsPythonPython37Libsite-packagesCryptoCipherBlowfish.py to Blowfish.cpython-37.pyc
....省略部分输出信息
byte-compiling C:UsersAdministratorAppDataLocalProgramsPythonPython37Libsite-packagesCryptoUtilrandpool.py to randpool.cpython-37.pyc
byte-compiling C:UsersAdministratorAppDataLocalProgramsPythonPython37Libsite-packagesCryptoUtilRFC1751.py to RFC1751.cpython-37.pyc
byte-compiling C:UsersAdministratorAppDataLocalProgramsPythonPython37Libsite-packagesCryptoUtilwinrandom.py to winrandom.cpython-37.pyc
byte-compiling C:UsersAdministratorAppDataLocalProgramsPythonPython37Libsite-packagesCryptoUtil_number_new.py to _number_new.cpython-37.pyc
byte-compiling C:UsersAdministratorAppDataLocalProgramsPythonPython37Libsite-packagesCryptoUtil__init__.py to __init__.cpython-37.pyc
byte-compiling C:UsersAdministratorAppDataLocalProgramsPythonPython37Libsite-packagesCrypto__init__.py to __init__.cpython-37.pyc
running install_egg_info
Writing C:UsersAdministratorAppDataLocalProgramsPythonPython37Libsite-packagespycrypto-2.6.1-py3.7.egg-info

出现 Writing C:UsersAdministratorAppDataLocalProgramsPythonPython37Libsite-packagespycrypto-2.6.1-py3.7.egg-info ,即表示安装成功。

文章来源于互联网,如有雷同请联系站长删除:pycrypto安装报错处理

发表评论