To build Python extension modules, you will need to have the same (or functionally identical) C compiler that was used to compile Python for your platform (OS).
Windows, Python 3.5 or above
Install Microsoft Visual C++ compiler for Visual Studio 2015 (not another version). Here is a direct link to the installer:
Windows, Python 2.7
Enthought Python is built on a standard Python 2.7 environment. On Windows, standard Python 2.7 supports only specific C++ compilers (https://docs.python.org/2/using/windows.html#compiling-python-on-windows).
Here is how to compile C extensions (including 64-bit extensions) using Microsoft Visual C++ Compiler for Python:
- Open a Canopy Command Prompt from Canopy's Tools menu or from the Windows Start menu
You can then "cd X:yourpath" to navigate to the Python code which you are building, and build your C extensions by entering:
python.exe setup.py build_ext --inplace --compiler=msvc
Any other version of Visual Studio post-2008 is not supported. Python 2 is built with the CRT9.0 which is included in Visual Studio 2008. Newer versions of the compiler use a new CRT (10 and higher), which should not be used with Python 2. For more information, please refer to:
The MinGW stack is another solution that is very often used on Windows. On 32-bit, it tends to work pretty nicely for some trivial cases, but has the very same drawbacks as using a different version of Visual Studio, mentioned above. On 64-bit, MinGW is not entirely stable.
Mac OS X
Please check (using the Terminal application) whether you already have gcc installed, by typing "gcc" at the command prompt. If you do not have gcc, you will need to download and install XCode from Apple:
and then install the "Command Line Tools" from within XCode (accessible from the XCode > Preferences window in the "Downloads" tab under "Components").
Note: If you are a user of OS X 10.9 or higher, please see the following article for important considerations regarding "gcc" provided by Xcode:
You will need to use your package manager (for example "apt" or "yum") to install gcc if it is not already available. Consult the documentation for your Linux distribution for details.
SDK: Software Development Kit
CRT: C Runtime (Library)