Skip to content

Python3 Windows Install PyCrypto module

If you are on Windows, using Python 3, you may face some issues when trying to install the outdated and no-longer-maintained pycrypto module.

Here’s how you can fix this. You will need to have Microsoft Visual Studio 14.0, which by default is located at the following path C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC. You will also need Visual Studio Toolkit 10, which by default is located at C:\Program Files (x86)\Windows Kits\10.

You can install both of them by just installing Visual Studio 2019 C/C++, or specifically the Visual Studio 2019 Build Tools. After you ensure that you have both of them, do the following

  1. In your environment variables, create a new entry name=VCINSTALLDIR and C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC. Take note that you should create them as a User variable, rather than a System variable.
  2. Save the environment variable
  3. Open cmd, enter the following set CL=/FI"%VCINSTALLDIR%\INCLUDE\stdint.h" %CL%
  4. Now, you can try to run pip install pycrypto again and see if you get any error. If you do, it likely shows a line like this C:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\ucrt\inttypes.h(31): error C2061: syntax error: identifier 'intmax_t', along with an exit status 2 somewhere in the logs.

To fix the above error, do the following

  1. Go to C:\Program Files (x86)\Windows Kits\10\Include\10.0.19041.0\ucrt and in the file inttypes.h, add the following lines of code and save.
    #define intmax_t long long
    #define uintmax_t unsigned long long
  2. Run pip install pycrypto again.
  3. After successfully installing pycrypto, you might want to go back and remove those 2 lines of code from inttypes.h

That’s it !

Enjoyed the content ? Share it with your friends !
Published inUncategorized

Be First to Comment

Leave a Reply

Your email address will not be published. Required fields are marked *