Python does not come installed by default on Windows machines. At the time of writing this, Python 2.7.11 is the most recent 2.X line and can be installed by downloading the python-2.7.11.msi
file from https://www.python.org/downloads/. We recommend installing the 64-bit version if supported by your hardware.
After executing the Python installer, you can run Python by clicking on the python.exe
file located in the C:\Python27
directory or from the command prompt at C:\Users\LPF>C:\Python27\python.exe
. This path may vary depending on customizations during installation.
The third, and easiest, method to run Python is to just type python
in the Command Prompt. To do this, we must add the location of the Python executable to our PATH variable. Python includes an automatic way of doing this, simply run the win_add2path.py
script in the command prompt. After the script runs, close and open a new command prompt to load the new PATH variable before typing python
.
C:\Users\LPF>C:\Python27\Tools\Scripts\win_add2path.py
You can also perform this manually by right-clicking My Computer, or This PC on Windows 8.1, and selecting Properties. On the left-hand side panel, select Advanced system settings followed by Environment Variables.
In the System variables box, select the Path variable and add the following (with the exception of the quotes) to the end ";C:\Python27;C:\Python27\Scripts
". The Python27
directory contains the python
executable, which we often invoke from the command line. The Scripts
directory contains multiple scripts such as pip
and easy_install
, which make installing third-party modules a breeze. With this now complete, you have successfully installed Python.
If you did this incorrectly, you would receive the following error when typing python
into the command prompt:
C:\Users\LPF>python 'python' is not recognized as an internal or external command, operable program or batc h file.
Make sure that you've closed and opened a new command prompt after updating the PATH variable. In addition, ensure that you've added the correct path information for the Python27
and Scripts
folders as illustrated earlier.