Setup Python 2.7.2 and MinGW on Windows XP

This post demonstrates how to setup and configure Python 2.7.2 and MinGW on Windows XP.

MinGW Installation

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.

  1. Right-click on this computer and select properties
  2. Go to the tab ‘Advanced’ and select ‘Environment variables’
  3. Select ‘Path’ from the ‘System Variables’ and click the ‘Edit button’
  4. Add the following paths to your variables: ‘C:\MinGW\bin;C:\MinGW\msys\1.0\bin;’
  5. Test them by opening a command prompt and typing the commands ‘gcc’ and then ‘awk’
  6. 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.

Python Installation

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:

Again, you have to configure your PATH environment variable to be able to use the ‘python’ and the ‘easy_install’ command directly.

  1. Add the following paths to your PATH system variable: ‘C:\Python27;C:\Python27\Scripts;’

Post-configuration steps

Now we need to configure Python’s compiler to be MinGW.

  1. Create the following file: C:\Python27\Lib\distutils.cfg
  2. Add the following content:
  3. 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\

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!

This entry was posted in MinGW, Programming, Python. Bookmark the permalink.

5 Responses to Setup Python 2.7.2 and MinGW on Windows XP

  1. KevinT says:

    Just two small mistakes. It should be C:\Python27\Tools\Scripts instead of C:\Python27\Scripts. And C:\Python27\Lib\distutils.cfg is not right location, the cfg file should be placed in C:\Python27\Lib\distutils\distutils.cfg

    • DJ says:

      You are correct on the directory for the distutils.cfg file but wrong for the “scripts” directory. Bart had it right, the directory that holds “easy_install” and every other script you’d need is in fact in C:\Python27\Scripts.

  2. Ash says:

    Thanks for the detailed and well written instructions.

  3. Pingback: Python:Python package install error – IT Sprite

  4. Kuba says:

    Works for me too, thank you. Tried python 3.5 and didnt work, but on 2.7 version everthing was ok.

Leave a Reply

Your email address will not be published.