Building Python extensions for Enthought Python

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:
https://download.microsoft.com/download/5/F/7/5F7ACAEB-8363-451F-9425-68A90F98B238/visualcppbuildtools_full.exe

 

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).

Microsoft released the Visual C++ Compiler for Python 2.7. Enthought Python users can use this compiler to build extensions following the instructions found on the Cython wiki:

Here is how to compile C extensions (including 64-bit extensions) using Microsoft Visual C++ Compiler for Python:

    1. Install Microsoft Visual C++ Compiler for Python

    1. Open a Canopy Command Prompt from Canopy's Tools menu or from the Windows Start menu
    2. 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

Unsupported environments:

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: 

https://msdn.microsoft.com/en-us/library/ms235460.aspx

http://siomsystems.com/mixing-visual-studio-versions/

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: 

https://developer.apple.com/xcode/

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: 

https://support.enthought.com/entries/26184115-OS-X-GCC-Clang-and-Cython-in-10-9-Mavericks

Linux

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.

 

GLOSSARY:

SDK: Software Development Kit

CRT: C Runtime (Library)

Have more questions? Submit a request

Comments

Powered by Zendesk