- User
- Which Microsoft Visual C++ compiler to use with a specific Python version ?
- Distutils notes
- Compilers Installation and configuration
- Microsoft Visual C++ 14.x with Visual Studio 2022 (x86, x64, ARM, ARM64)
- Microsoft Visual C++ 14.2 standalone: Build Tools for Visual Studio 2019 (x86, x64, ARM, ARM64)
- 5 лучших IDE для Python и не только
- 1. Atom
- Плюсы:
- Минусы:
- 2.Microsoft Visual Studio
- Плюсы:
- Минусы:
- 3. PyCharm
- Плюсы:
- Минусы:
- 4.Spyder
- Плюсы:
- Минусы:
- 5.Sublime Text
- Плюсы:
- Минусы:
User
Even though Python is an interpreted language, you may need to install Windows C++ compilers in some cases. Unlike Linux, compilers for Windows are not included by default in the OS.
- Install a non-pure Python package from sources with Pip (if there is no Wheel package provided).
- Compile a Cython or Pyrex file.
Microsoft provides official C++ compilers called Visual C++, you can find them bundled with Visual Studio or, for some versions, in standalone distributions. Some alternative compilers exist like MinGW, but incompatibilities may occur with a CPython official distribution that is built with Microsoft Visual C++.
The compiler’s architecture must be the same as Python’s (for example: if you use Python 64bit, you have to use an x64 compiler).
Which Microsoft Visual C++ compiler to use with a specific Python version ?
Each Python version uses a specific compiler version (e.g. CPython 2.7 uses Visual C++ 9.0, CPython 3.3 uses Visual C++ 10.0, etc). So, you need to install the compiler version that corresponds to your Python version :
Please also have a look at The Python Dev Guide for Windows to check for additional requirements or updates to the above table.
Distutils notes
- distutils only supports the very minimum of compiler setups. The sections in this guide corresponding to them explicitly mention distutils.
- For other setups, you need to run the compilation from the «SDK prompt» of the corresponding toolchain and set the DISTUTILS_USE_SDK environment variable to a non-empty value.
Compilers Installation and configuration
Compatible architectures are specified for each compiler in brackets.
Before do anything, install or upgrade the Setuptools Python package. It contain compatibility improvements and add automatic use of compilers:
pip install --upgrade setuptools
Microsoft Visual C++ 14.x with Visual Studio 2022 (x86, x64, ARM, ARM64)
- Install Microsoft Visual Studio 2022 (or later).
- Install the Python development workload and the optional Python native development tools option.
- Install the latest Windows SDK (under Native development in the installer).
- Optional: Set $env:PlatformToolset to your toolset version before building, if it doesn’t detect it.
- Update to the latest setuptools Python package version.
For additional details, please have a look at the Windows section of the Python Development Guide and the PCbuild/python.props file for full details on how Python is built on Windows.
At the time of this writing, CPython is built using VC++ 14.3 (Jan 2022).
Microsoft Visual C++ 14.2 standalone: Build Tools for Visual Studio 2019 (x86, x64, ARM, ARM64)
- Install Microsoft Build Tools for Visual Studio 2019.
- In Build tools, install C++ build tools and ensure the latest versions of MSVCv142 — VS 2019 C++ x64/x86 build tools and Windows 10 SDK are checked.
- The setuptools Python package version must be at least 34.4.0.