Setting up Python and Easy_Install on Windows 7

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 python and if you see this, you’re on to a winner…

Microsoft Windows [Version 6.1.7600]
Copyright (c) 2009 Microsoft Corporation. All rights reserved.

C:\Users\adelegilpin>python
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

C:\Python27>

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

Done!

To use easy_install to get new libraries, just use the following syntax: easy_install <library name> (e.g. easy_install postcodes)

About these ads

9 comments

  1. Very Helpful…

  2. […] Setting up Python and Easy_Install on Windows 7 (adesquared.wordpress.com) […]

  3. Hello,

    I got stucked in step number 5.
    When I open the command prompt and type “python ez_setup.py install” then an error message is displayed “syntax error”
    I do not know why is this happening and how to solve it. Any help?

    I also tried to run the ez_setup.py script and I get the following:
    Extracting in c:\users\alice\appdata\local\temp\tmpqhiqcp
    Now working in c:\users\alice\appdata\local\temp\tmpqhiqcp\setuptools-0.8
    Installing Setuptools
    Something went wrong during the installation.
    See the error message above.

    Something is not working properly. Do you have any idea what could it be?
    Any help on the subject will be very much appreciated
    Thank you !!

    1. Hi Mauricio,

      It looks like it extracted it successfully in to c:\users\alice\appdata\local\temp\tmpqhiqcp\setuptools-0.8 and so I would use the command prompt to go in to that location and try running “python ez_setup.py install” again from within there – that should work.

      Another thing to check is what version of Windows you are using (32 or 64 bit) and make sure you’ve downloaded and installed the correct version of setuptools.

      I hope that helps and good luck!

      Cheers,
      Adele

  4. Really helpful. Thank you so much!

  5. Many thanx for providing excellent documentation. Identifying each stop clearly is very helpful. You don’t assume the reader knows where to ez_setup file or other small details that an derail the novice reader.

  6. Sitaram Khadka · · Reply

    You are great!!!!

  7. This is the easiest most clear and helpful instructions to install python and other packages that I have come across on the web. Thanks a lot.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

%d bloggers like this: