This post demonstrates how to setup and configure Python 2.7.2 and MinGW on Windows XP.
You can get the MinGW installer from here.
When you run it, please select ‘download latest repository catalogues’. Next you select a folder (i.e. C:\MinGW) and the programming support you require: C and C++ (I leave Fortran and ObjC deselected). It’s a must to have the MinGW Developer Toolkit installed as well, if you select this option you’ll get MSYS as well. (The basic must have commands like awk).
Next you have to configure your PATH environment variable.
- Right-click on this computer and select properties
- Go to the tab ‘Advanced’ and select ‘Environment variables’
- Select ‘Path’ from the ‘System Variables’ and click the ‘Edit button’
- Add the following paths to your variables: ‘C:\MinGW\bin;C:\MinGW\msys\1.0\bin;’
- Test them by opening a command prompt and typing the commands ‘gcc’ and then ‘awk’
- Tip: If you want to check your environment variables in the command prompt, use the command ‘echo %PATH%’. If you change your variables, you have to reopen the command prompt to have the new settings work.
Next it’s time to install Python! You can get the python installer from here.
When you install it, you have to specify a installation location i.e. C:\Python27
After the installation I recommend to install a handy tool that will easy setup of packages, named ‘setuptools’. This package is available here: http://pypi.python.org/pypi/setuptools
Again, you have to configure your PATH environment variable to be able to use the ‘python’ and the ‘easy_install’ command directly.
- Add the following paths to your PATH system variable: ‘C:\Python27;C:\Python27\Scripts;’
Now we need to configure Python’s compiler to be MinGW.
- Create the following file: C:\Python27\Lib\distutils.cfg
- Add the following content:
- Save the file
You might encounter the following issue when compiling Python software using MinGW:
gcc: error: unrecognized command line option '-mno-cygwin'
You can fix this easily by editing the following file: C:\Python27\Lib\distutils\cygwinccompiler.py
Look for the class: Mingw32CCompiler
Alter the executables, so that the deprecated option is now deleted:
self.set_executables(compiler='gcc -O -Wall',
compiler_so='gcc -mdll -O -Wall',
compiler_cxx='g++ -O -Wall',
linker_so='%s %s %s'
% (self.linker_dll, shared_option,
There, you should be ready to play new development environment!