Python development on Windows – Setuptools & Pip configuration

Sometimes installing Python modules on Windows is a pain. You have seen the setuptools error message complaining that you don’t have Visual Studio 2003 installed? Yes, well then you have probably seen that the fix is easy:

python build –compiler=mingw32 install

But what if you want to install using easy_install or pip? or you want to use a pip requirements.txt file in a virtualenv? I have the solution for you.

First: Install MinGw including gcc, make and all the other regular goodies you would have on a Unix system.

Second: Add your \MinGw\bin directory to your path.

Third: If you are using an older version of Python (pre 2.6.6) you will have to manually set your HOME environment variable to your user directory.

Finally: In your C:\Users\Admin (where Admin is your Windows user account, Windows XP users, adjust to \Documents and Settings\ appropriately), create a text file called pydistutils.cfg and paste in the following options:

compiler = mingw32

That’s it! Enjoy using the magical goodness of pip and easy_install on packages like Twisted, SimpleJson (with speedups) and postgres

  • Guandalino

    Many many thanks, this procedure solved a problem 🙂

  • Thank you so much! It saved my brain! One less error I guess…