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
- In your environment variables, create a new entry name=
VCINSTALLDIR
andC:\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. - Save the environment variable
- Open cmd, enter the following
set CL=/FI"%VCINSTALLDIR%\INCLUDE\stdint.h" %CL%
- 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 thisC:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\ucrt\inttypes.h(31): error C2061: syntax error: identifier 'intmax_t'
, along with anexit status 2
somewhere in the logs.
To fix the above error, do the following
- Go to
C:\Program Files (x86)\Windows Kits\10\Include\10.0.19041.0\ucrt
and in the fileinttypes.h
, add the following lines of code and save.#define intmax_t long long
#define uintmax_t unsigned long long - Run
pip install pycrypto
again. - After successfully installing
pycrypto
, you might want to go back and remove those 2 lines of code frominttypes.h
That’s it !
Be First to Comment