Installing Python 2.7 on Windows

What You Need for This Project

Downloading and Installing Python

In a Web browser, go to https://www.python.org/download/

Scroll down to find the latest version of Python 2.7, and click the blue Download link, as shown at the bottom of the image below.

On the next page, click the appropriate Windows installer for your system, either 32-bit or 64-bit.

Double-click the downloaded file.

Troubleshooting

If the installer file won't open, try these actions:
  • Right-click the file and click Properties. At the bottom of the Properties sheet, click Unblock.
  • Launch the installer from a Command Prompt, not from the GUI
In the "Select whether to install Python 2.7.13 for all users of this computer" window, accept the default option to "Install for all users" and click Next".

In the "Select destination directory" window, accept the default directory and click Next".

In the "Customize Python 2.7.13" window, scroll to the bottom of the list, click the arrow next to "Add python.exe to Path", and click "Entire feature will be installed on local hard drive", as shown below.

Click Next".

In the "Complete the Python 2.7.13 Installer" window, click Finish".

Testing the Python Installation

Open a Command Prompt window and execute this command.
python
You should see Python launch, as shown below, but it usually does not, because the Python installer doesn't work correctly. If that happens, follow the instructions in the Troubleshooting box below.

Troubleshooting

If python won't launch, you can fix it with an Administrator Command Prompt window.

Click Start (on Windows 8, press the Windows Logo key on your keyboard) and type this search term:

cmd
When Windows finds "Command Prompt", right-click it and click "Run as administrator".

If a "User Account Control" box appears, click Yes.

In the Administrator Command Prompt window, execute these commands, as shown below.

cd c:\Windows
mklink /H python.exe c:\python27\python.exe

Your machine is now ready to do simple Python projects, such as the ones in the Violent Python book.

Installing Crypto Libraries

To do cryptography projects, n the Administrator Command Prompt window, execute this command to exit the Python prompt:
exit()
In the Administrator Command Prompt window, execute these commands:
pip install pycryptodome
python
from Crypto.Cipher import AES
The steps should complete without errors, as shown below.

References

PyCryptodome Documentation


Posted 4-3-17 by Sam Bowne
Revised 6-11-17
Windows download image updated 6-23-18
Pycryptodome added 3-5-19