Install Python 2.7, VPython and pip on Windows
In this post I’m going to describe a small how-to guide to install Python 2.7 (32 bits), which is the version I actually use for my posts. I’m going to include as well the installation of the interactive development environment (IDE) that I currently use called VPython. And finally, I will show how to install a package management system for python called pip, which makes your life very easy when installing Python libraries. Bear in mind that there are plenty of different ways to install Python, from completely manual installations to full packages as Anaconda which come with all that you need in a single installation file.
First of all, why do I install version 2.7 and 32 bits?
When you go to the python.org downloads page, you will face your first decision: should I download the new Python 3.4 or the previous version 2.7? Well, assuming that you are making your first steps with Python, the recommendation is to start with version 2.7 because is the most widely used, that is, if you face a problem, it is easy to find a solution with a simple search in google or in stack overflow). Also there’s a huge number of libraries already developed for Python 2.7 and due to problems with backwards compatibility in Python 3, not all of them are available in the newer version. If you have more questions about Python 3, you can find some answers here.
Also, it is also recommended to use the 32 bits version and not the 64 bits version, even if you computer is a Windows 64 bits machine, there are two reasons. First, the 32 bits version requires less RAM memory for your programs, although you probably don’t have to worry about using all the available RAM memory of your system. The second reason is that not all the libraries work with the 64 bits version so, similar as with the newer Python version, you will be safer at the beginning if you stick with the 32 bits version.
Remember that this decisions will made your life easy at the beginning, but feel free to play with other versions of the software when you feel confident with Python.
Ok, how do I install Python 2.7?
First you have to download the Python 2.7 msi file, you can go to python.org downloads page or just click here. Once it is downloaded run the program and just follow the instructions. In a few minutes you will have installed Python in your local drive. If you don’t change anything (and probably you shouldn’t) it will be on C:\Python27
You should be aware of the location of your local Python installation because libraries will use this folder to install themselves. In the few cases where libraries come in an installation package, they will usually find the folder by themselves but it is helpful if you check the installation path to prevent further trouble.
Installing an interactive development environment (IDE)
Now that you have Python 2.7 installed, there are many ways to use it. Right now, you can write your program in a text editor as Window’s Notepad and then run it using the command prompt. However, there’s an easier way which requires the installation of an interactive development environment (usually called just IDE). As you can see here, there are many IDEs available for Python, each one with its own pros and cons. Personally, I’ve used Spyder which is nice for people looking for a MATLAB-like experience with Python. In this case, I’m going to use VPhyton because I’m very interested in the visual module that comes with this IDE. Also, I find that is a very simple IDE to focus on your code, you can see an example below:
As you can see in the picture, VPython IDE is very similar than Notepad, however, it recognizes the Python commands -colored words – which helps with debugging and running programs is very, very easy: you just go to “Run” and then “Run module” or even faster and easier, just press ‘F5’.
Installing VPython is also very straightforward, you go to the VPhyton downloads page or just click here. It will open a sourceforge.net page and your download will start in a few seconds. Once the file is downloaded, just run it, and follow the instructions. Remember to check that VPython finds your Python 2.7 installation!
Help with libraries, installing pip
If you have downloaded python 2.7 you probably already have pip installed, you can check that if you do the following:
1- Open the command prompt (if you don’t know how to do it, check it here for windows 7, 8 or 10)
2- You will get something like this:
3- Here, you can type:
python -m pip install -U pip
This will try to upgrade your installation of pip, there are other ways to check if you have pip installed, but with this you will automatically upgrade it if you don’t have the latest version. Several things may happen now:
– If you receive a message like: Requirement already up-to-date in c:\python27\lib\site-packages, then you are good to go.
– If you see that the computer starts downloading and installing pip, just wait until in finished.
– If the computer cannot find pip, you have to install it, first download pip from here (don’t left click it!, press right click and then ‘Save link as’ and press ok to download ‘get-pip.py’) . Then go to your command prompt and type the following:
– If the computer cannot find python, you have to do first the next part, and then come back
Wait for the program to install, and check again if you have the latest version. Alternatively, you can go to the downloaded file, right click, choose ‘Open with’ and then look for python to open it. Both ways will install pip on your system.
Change environment variables
If the installer didn’t do it automatically, you have to tell windows where to look for Python. So you need to change the environment variables. This may sound scary but is is actually pretty easy: on Windows press the start button and then search for ‘environment variables’ and click on the result. You should see a picture similar than the left side picture below.
Click on the ‘Environment Variables’ button on the bottom (red square on the left picture) and you should see the image on the middle. Now, on the lower side of the window you can find ‘System variables’. Look for ‘Path’, select it and click on the ‘Edit’ button. You have to add the following at the end of the variable value: C:\Python27; C:\Python27\Scripts; Press now Ok twice and Apply to save the changes.
You are now all set to work with Python!!
If you need help or have any suggestions, don’t hesitate in contacting me using the contact form.