Howto get a working python development environment under Windows
Published: sep 27, 2010
Odd title for me? Oh yes! Since my last career change I have only worked with Windows. But putting Python totally behind me is hard, it itches sometimes in my fingers. So I have resumed the development of my home brewn HTPC called PyMBrowser (that's Python Media Browser, one of the best names I've come up with;-). To get the development for Pymbrowser up and running on windows I hade to
This is a small list to get a proper python development environment under Windows. And with proper I include niceties like pip, virtualenv, virtualenvwrapper (oh yeah!), QT etc.
-
Install Python
Just head on to http://www.python.org/ and install the right version for your computer. I decided to use the 32-bit version even though I'm using Windows 7 64-bit, this to minimize all sources to errors. Add Python to your path (c:\Python27 for me example), also add c:\Python27\Scripts to the path, to make lots of things easier. To make your path changes active you just have to close the cmd and start a new one.
-
Install MingW
Download MingW from SF (http://sourceforge.net/projects/mingw/), you just have to click the big green button pointing to a tiny file that weighs in at ~500K. This is just the installation, it will get the stuff it need from the net. Don't know if it's necessary, but I also choose c++ as addon. Add c:\MinGw\bin (or wherever you install it) to your path
(Thanks http://blog.markstahler.ca/2010/08/python-development-on-windows-setuptools-p... for guidance)
-
Install Setuptools
Just to download the matching verion from http://pypi.python.org/pypi/setuptools I choose the .exe-file so just double click and it detected my python installation and installed itself in the right place.
(Thanks for the packaging to the whole of the setuptools-team!)
-
Install pip
Open a cmd and run:
easy_install.exe pip
I did get the command above to work, but, I couldn't get pip to actually install anything (it failed due to some windows permissions), so I'm using the solution below.
Download the tar.gz from http://pypi.python.org/pypi/pip and unpack. Install by extracting the tar.gz file (7-zip is a nice tool for this) Step into the right folder and run
python setup.py install(If this does not work you maybe have to run:python setup.py build –compiler=mingw32 install) -
Install virtualenv If everything uptil now has worked without a hitch then this is even easier:
pip install virtualenvEasy huh? -
Install virtualenvwrapper
One step left, almost. Justin Driscoll has rewritten the original virtualenvwrapper from bash to python (what a luck for us windows-users (and fish-shell-users too)), you can find the script at http://justindriscoll.us/2009/03/virtualenv-helper-for-windows.html
Just copy the code, create a new file called env.py in c:\Python27\Scripts, paste and save.
You should now be able to run
env.py -land see all of your virtualenvs (which should be none right now)
That should be it, if I have forgotten something, please make a comment and I correct it as soon as possible.