'Microsoft Windows Python-3.6 PyCrypto installation error

pip install pycrypto works fine with python3.5.2 but fails with python3.6 with the following error:

inttypes.h(26): error C2061: syntax error: identifier 'intmax_t'



Solution 1:[1]

I've succeeded install pycrypto 2.6.1 on python 3.6, Windows 10, Visual Studio 2017.

  1. Open "x86_x64 Cross-Tools Command Prompt for VS 2017" with administrator privilege in start menu.

  2. set CL=-FI"%VCINSTALLDIR%Tools\MSVC\14.11.25503\include\stdint.h"

  3. pip install pycrypto

enter image description here

Solution 2:[2]

Thanks to user1960422's answer.
PowerShell steps for pycrypto 2.6.1 (via simple-crypt) / Python 3.6 / Windows 10:

$env:VCINSTALLDIR="C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC"
$env:CL="-FI`"$env:VCINSTALLDIR\INCLUDE\stdint.h`""

Successful simple-crypt / pycrypto install

I also needed to follow the answer in: https://stackoverflow.com/a/24822876/8751739 to fix a winrandom module error.

Solution 3:[3]

Use PyCryptodome instead of pycrypto. pycrypto is discontinued and is no longer actively supported. PyCryptodome exposes almost the same API as pycrypto (source).

Solution 4:[4]

I've succeeded install pycrypo 2.6.1 on python 3.6 and windows 10.

  1. Set an environment variable like below. visual studio installed directory
  2. Open cmd.exe
  3. Activate virtualenv
  4. Download pycrypto 2.6.1 release from github and unzip it.
  5. set an environment variable for pycrypto set CL=/FI"%VCINSTALLDIR%\\INCLUDE\\stdint.h" %CL%
  6. Run setup command python setup.py install
  7. my result is here enter image description here

I would be glad if this could be help someone.

Solution 5:[5]

  • Uninstall your current Python version

  • Install Python for amd64 architecture

  • Follow the other accepted solutions:

    • open "x86_x64 Cross-Tools Command Prompt for VS 2017"
    • Add the new enviroment varible for your Visual Studio MSVC install path
    • set CL=-FI"%VCINSTALLDIR%Tools\MSVC\14.11.25503\include\stdint.h"
    • pip install pycrypto

Solution 6:[6]

For ppl who is encountering same situation as mine:

Env

  • Windows 10 Enterprise v10.0.18363 Build 18363
  • Python 3.8

Steps

  1. Download Microsoft C++ Build Tools at https://visualstudio.microsoft.com/visual-cpp-build-tools/
  2. Run above setup exe and install default components
    • MSVC v142 - VS 2019 C++ x64/x86 build tools
    • Windows 10 SDK
    • C++ CMake tools for windows
    • Testing tools core features - Build Tools
    • C++ AddressSanitizer(Experimental)
  3. Reboot PC
  4. Start menu > x64 Native Tools Command Prompt for VS 2019, a cmd window will pop up
  5. Execute set CL=-FI"C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.27.29110\include\stdint.h"
  6. Run pip install pycrypto in a cmd window(may need admin privilege)

Solution 7:[7]

For me this fixes it:

with Python 2, I have

sudo apt-get install python-dev  \
     build-essential libssl-dev libffi-dev \
     libxml2-dev libxslt1-dev zlib1g-dev \
     ...

with Python 3, I need

sudo apt-get install python3 python-dev python3-dev \
     build-essential libssl-dev libffi-dev \
     ...

Installing python-dev python3-dev fixes it for me!

Solution 8:[8]

C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Auxiliary\Build>vcvars64.bat

** Visual Studio 2019 Developer Command Prompt v16.11.14 ** Copyright (c) 2021 Microsoft Corporation ********************************************************************** [vcvarsall.bat] Environment initialized for: 'x86_x64'

C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools>set CL=-FI"C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.29.30133\include\stdint.h"

C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools>pip install pycrypto Collecting pycrypto Using cached pycrypto-2.6.1.tar.gz (446 kB) Preparing metadata (setup.py) ... done Building wheels for collected packages: pycrypto Building wheel for pycrypto (setup.py) ... done Created wheel for pycrypto: filename=pycrypto-2.6.1-cp39-cp39-win_amd64.whl size=528832 sha256=250926fc0e06b4c1ed9c2fb16ad9b4723984ef68c1e5383b26c974235536a0ae Stored in directory: c:\users\volka\appdata\local\packages\pythonsoftwarefoundation.python.3.9_qbz5n2kfra8p0\localcache\local\pip\cache\wheels\9d\29\32\8b8f22481bec8b0fbe7087927336ec167faff2ed9db849448f Successfully built pycrypto Installing collected packages: pycrypto Successfully installed pycrypto-2.6.1

C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools>

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Jossef Harush Kadouri
Solution 2
Solution 3 robertspierre
Solution 4 user1960422
Solution 5 Delrius Euphoria
Solution 6
Solution 7 Jee Mok
Solution 8 Volkan KIRIK