Python Step on the road-python-3.6 installation Pycrypto 2.6.1 A variety of incurable diseases and solutions

Source: Internet
Author: User

Recent contact with the company's background management system development, which involves the encryption module PYCRYPTO.
The point is coming!!! Knock the blackboard!!!
Pycrypto in Pycharm with the other modules, Pip install Pycrypto installed is 1.4.1, and although the module can install successfully, but in fact the code is still unable to correlate, the operation will report an exception.
Baidu Solution: Download Pycrypto Source Installation
But the installation of Pycrypto source code is not so simple thing, here the past few days trampled the pits are recorded.

1. Download Pycrypto Source code

Official website: https://www.dlitz.net/software/pycrypto/
Github:https://github.com/dlitz/pycrypto
Download source extract, win+r run cmd, go to unzip folder

install
    • 1

If you do not report an error, see

running install_egg_info
    • 1

Congratulations, you don't have to step on the pit, you can just close this thing and write the code happily.

2. Display unable to find vcvarsall.bat during installation

This is the window Environment installation module More common problem, this time you Baidu words most articles will tell you to download vs,python2 words installed Vs2010,python3 words installed vs2013
Focus!!!!!!!!
Don't worry about installing VS, it's been installed for hours, and here I've loaded vs and unloaded and wasted a day and a half.
Python has a deep pit! Different versions of Python correspond to different versions of VS, and the corresponding version is in the path where Python is located \lib\distutils_msvccompiler.py
Like my path is E:\Python\Python36\Lib\distutils_msvccompiler.py.
Open Find Def _find_vcvarsall (Plat_spec)
Under this function there is a if version >= 14 and version > best_version

The version >= 14 here is the corresponding VS release number, If you're python3.6 the same as me, it should be here is 14, before you see other blogs, not to see the version number here, first installed VS2010, then installed 2013, and then unloaded the corresponding version number of the vs2015, where vs version number corresponds to the following:
msvs2005 version number 8.0, corresponding to the environment variable Vs80comntools
msvs2008 version number 9.0, corresponding to the environment variable Vs90comntools
msvs2010 version number 10.0, corresponding to the environment variable Vs100comntools
msvs2012 version number 11.0, corresponding to the environment variable Vs110comntools
msvs2013 version number 12.0, corresponding to the environment variable Vs120comntools
msvs2015 version number 14.0, corresponding to the environment variable Vs140comntools

3. Install the corresponding version of MSVs (Microsoft Visual Studio)

If it is visual Studio 2015, provide a Baidu experience on Baidu network disk to everyone
Http://pan.baidu.com/s/1eSueWLG
If you do not need to use VS development, install Community free version of it, there is no need to tangle professional version of what
Installation process to be aware that the recommended installation time to choose Custom (from Baidu experience, because has been installed after opening a bit different)

Remember to tick vc++2015 and Python Tools. Web Deveolper Tools It's best to hook it up.
But my installation process is not so smooth, tears rush ~

Installing some modules fails, then I reinstall. Because the main vs2015 installation is successful, it is only checked

    • vc++2015
    • Python Tools
    • Web Deveolper Tools
      These three modules, about 500M, re-install the prompt all success
      Many people say to change the environment variables after loading,
 python2:set VS90COMNTOOLS=%VS140COMNTOOLS% python3:set VS100COMNTOOLS=%VS140COMNTOOLS%
    • 1
    • 2

python3.6 version may not need this, but also record for you crossing for reference only. Anyway, I don't need to change, because then I stepped on another hole.
Re-entry into the Pycryto folder is python setup.py install still displayed
building ‘Crypto.Random.OSRNG.winrandom‘ extension

Running installrunning buildrunning build_pyrunning BUILD_EXTWARNING:GMP or Mpir library not found; Not building crypto.publickey._fastmath.building ' Crypto.Random.OSRNG.winrandom ' Extensionc:\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\includewinrand.cc:\program Files (x86)\ windows Kits\10\include\10.0.10240.0\ucrt\inttypes.h (+): Error c2061:syntax error:identifier ' intmax_t ' C:\program Files (x86)\ windows Kits\10\include\10.0.10240.0\ucrt\inttypes.h: Error C2061:syntax error:identifier ' REM ' C:\program Files (x86)\ windows Kits\10\include\10.0.10240.0\ucrt\inttypes.h: Error c2059:syntax error: '; ' C:\program Files (x86)\ windows Kits\10\include\10.0.10240.0\ucrt\inttypes.h: Error c2059:syntax Error: '} ' C:\program Files (x86)\ windows Kits\10\include\10.0.10240.0\ucrt\inttypes.h (+): Error c2061:syntax error:identifier ' imaxdiv_t ' C:\program Files (x86)\ windows Kits\10\include\10.0.10240.0\ucrt\inttypes.h (+): Error c2059:syntax error: '; ' C:\program Files (x86)\ windows Kits\10\include\10.0.10240.0\ucrt\inttypes.h (+): Error C2143:syntax error:missing '{' Before ' __cdecl ' C:\program Files (x86)\ windows Kits\10\include\10.0.10240.0\ucrt\inttypes.h: Error c2146:syntax error:missing ') ' before identifier ' _number ' C:\program Files (x86)\ windows Kits\10\include\10.0.10240.0\ucrt\inttypes.h: Error c2061:syntax error:identifier ' _number ' C:\program Files (x86)\ windows Kits\10\include\10.0.10240.0\ucrt\inttypes.h: Error c2059:syntax error: '; ' C:\program Files (x86)\ windows Kits\10\include\10.0.10240.0\ucrt\inttypes.h: Error C2059:syntax Error: ') ' C:\program Files (x86)\ windows Kits\10\include\10.0.10240.0\ucrt\inttypes.h: Error C2143:syntax error:missing '{' Before ' __cdecl ' C:\program Files (x86)\ windows Kits\10\include\10.0.10240.0\ucrt\inttypes.h (+): Error c2146:syntax error:missing ') ' before identifier ' _numerator ' C:\program Files (x86)\ windows Kits\10\include\10.0.10240.0\ucrt\inttypes.h (+): Error c2061:syntax error:identifier ' _numerator ' C:\program Files (x86)\ windows Kits\10\include\10.0.10240.0\ucrt\inttypes.h (+): Error c2059:syntax error: '; ' C:\program Files (x86)\ windows Kits\10\include\10.0.10240.0\ucrt\inttypes.h (+): Error C2059:syntax Error: ', ' C:\program Files (x86)\ windows Kits\10\include\10.0.10240.0\ucrt\inttypes.h: Error C2059:syntax Error: ') ' C:\program Files (x86)\ windows Kits\10\include\10.0.10240.0\ucrt\inttypes.h (): Error C2143:syntax error:missing '{' Before ' __cdecl ' C:\program Files (x86)\ windows Kits\10\include\10.0.10240.0\ucrt\inttypes.h (): Error C2143:syntax error:missing '{' Before ' __cdecl ' C:\program Files (x86)\ windows Kits\10\include\10.0.10240.0\ucrt\inttypes.h (+): Error C2143:syntax error:missing '{' Before ' __cdecl ' C:\program Files (x86)\ windows Kits\10\include\10.0.10240.0\ucrt\inttypes.h (): Error C2143:syntax error:missing '{' Before ' __cdecl ' C:\program Files (x86)\ windows Kits\10\include\10.0.10240.0\ucrt\inttypes.h: Error C2143:syntax error:missing '{' Before ' __cdecl ' C:\program Files (x86)\ windows Kits\10\include\10.0.10240.0\ucrt\inttypes.h (c2143:syntax): Error error:missing '{' Before ' __cdecl ' C:\program Files (x86)\ Windows kits\10\include\10.0.10240.0\ucrt\inttypes.h (): 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)\\Microsof T Visual Studio 14.0\\VC\\BIN\\x86_amd64\\cl.exe ' failed with exit status 2   
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21st
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
4. Solve building ' Crypto.Random.OSRNG.winrandom ' extension

1. Add the VC environment variable, set the user environment variable, the focus here!!! is a user environment variable, not a system environment variable

Variable name: VCInstallDir
(The variable value is the VC under the VS installation path, this is the default)
Variable Value: C:\Program Files (x86) \microsoft Visual Studio 14.0\VC
2. Win+r run cmd, execute command set CL=/FI "%vcinstalldir%\include\stdint.h"%cl%
3. Re-enter the Pycryto folder python setup.py install and see
Can show running install_egg_info that the installation was successful.

5. Note Whether it is crypto or crypto, case sensitive

After I install successfully here, the code Alt+enter automatically associates the

from crypto.Cipher import AES
    • 1

Then the code to run an error, click inside the AES import is

from Crypto.Cipher import _AES
    • 1

Small partner if you encounter the same problem as me, you can manually enter the Python\lib, my path is
E:\Python\Python36\Lib
Then change the folder crypto to crypto. Change lowercase to uppercase, refresh, perfect run ~ ~ ~

Python Step on the road-python-3.6 installation Pycrypto 2.6.1 A variety of incurable diseases and solutions

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.