This weekend, I needed to set up Python on a Windows 7 virtual machine that I had set up on my Mac. I don’t know why, but I always seem to have a problem installing Python and setting up the environment and so I’m going to document the process here so that in X months time when I need to do it again, I just need to follow my own instructions!
As part of the process, I also install easy_install to install libraries and so I’ll also document that here.
1. Download the Python Windows installer from here -> http://www.python.org/download/ (I downloaded Python 2.7.5) and run the executable on your machine.
2. Run the installer – I normally leave all the defaults as they are, so end up installing it in C:\Python27
3. Once installed, SET UP YOUR ENVIRONMENT VARIABLES, I can not express how important this is as you’ll hit so many problems without do it (try opening the command prompt and typing python to see Windows shrug its shoulders and say “huh…dunno…”)
- If you haven’t played with environment variables before, just stick to following these instructions as you can set them up through the Windows GUI.
- Right click on “My Computer”, select “Properties” > “Advanced system settings” and click on the “Environment Variables” button
- In the System Variables box, find the variable called “path” and click on the “Edit…” button
- In the “Variable value” box, at the end of the entry, add the following text: ;C:\Python27;C:\Python27\Scripts (note the leading semi colon, also note that I’m using the default installation folder – if you have installed Python elsewhere, just change the path structure).
- Click “OK” a couple of times and hey presto, your environment variables are set up.
- To test it has worked, open a new command window and type in
pythonand if you see this, you’re on to a winner…
Microsoft Windows [Version 6.1.7600]
Copyright (c) 2009 Microsoft Corporation. All rights reserved.
Python 2.7.5 (default, May 15 2013, 22:43:36) [MSC v.1500 32 bit (Intel)] on win32
Type “help”, “copyright”, “credits” or “license” for more information.
4. The next step in the process is to set up easy_install and so we need to go to the setuptools page (links to version 0.8) and download the ez_setup.py script (I normally put it straight in to my Python27 folder).
5. Open a command prompt and type
python ez_setup.py install – you’ll see a load of code whizz by which will hopefully end as follows;
Processing dependencies for setuptools==0.8
Finished processing dependencies for setuptools==0.8
6. easy_install has now been set up and you can test to see if it is there, by typing
easy_install in to a command prompt, which will throw an error about no URLs, you know that the tool has been set up successfully
To use easy_install to get new libraries, just use the following syntax:
easy_install <library name> (e.g.