Mike Ryu

    BMS Software Engineering & Computer Science

    Python Installation Guide for Windows OS

    In addition to installing Python interpreter, some steps to "connect" the Windows OS and the interpreter is necessary to be able to use Python in Windows.

    This guide explains how to let Python Installer take care of that for you ticking a couple of checkboxes, and what to do if you forgot to do so and you're left to make the "connection" yourself.

    Because we are also trying to familiarize ourselves with the Unix environment, this guide also includes the installation of Git Bash, a Unix emulator you can run on Windows.

    Please Note This guide was prepared with an assumption that Python 3.6 is being installed on Windows 10 (64-bit). If you are following this guide at a later time or you have older or newer version of Windows, the instructions might not apply 100% for you. Nevertheless, the general steps to achieve the same goal should remain applicable.

    "Connecting" Windows and Python

    If you've been directed here to fix the problem of not being able to run python command on your Command Prompt or Git Bash after installing Python using the Installer, you can skip to step 6.

    Steps to Install Python and Git Bash

    1. Go to the latest Python Release page (version 3.6.4 at the time of writing) to download the latest version of Windows Python Installer. Select 'Windows x86-64 executable installer.'


    2. Go to Git download page to download the Git Installer for Windows.


    3. We'll install Python first. Once the download is completed, open (run) the executable file for Python Installer. Keep this internet browser window open for later when we install Git.


    4. On the first screeen, note the installation path shown under 'Install Now' button (shown below with a dotted round box). You will need this later (in step 10).

      If you want the installer to take care of "connecting" Windows and Python automatically, you must check the box marked 'Add Python 3.6 to PATH.' Also check the box marked 'Install launcher for all users (recommended).' Once these are ready, click 'Install Now.'


    5. At the end of the installation, you'll see a button marked 'Disable path length limit.' Click it and authorize Python Installer to make the change.


    6. Once the installation has been completed, open Command Prompt (press Windows + R, then type cmd.exe, then hit Enter). If the installer successfully connected Windows and Python, you should see the response similar to below when you type in python. If this is the case, skip to step 15.

      If the installer was not successful at connecting Windows and Python (most likely because you forgot to tick the box in step 4), you might see the response similar to below when you type in python. If this is the case, continue to step 7 below.


    7. At this point, we must manually make the connection. In reality, all we need to do is let Windows know that python is now one of the available commands. We do this by editing the System Environment Variables. Type 'Env' on the start menu's search bar as shown below, and select the item marked 'Edit the system environment variables.'


    8. You'll see System Properties window pop up. Click on 'Environment Variables ...' button at the very bottom.


    9. Environment Variables window should pop up now. Under System Variables, find the Path variable (it might be spelled with uppercase or lowercase letters, but there will only be one Path), and click 'Edit.' Edit environment variable dialog will open.


    10. If you noted the installation path shown under 'Install Now' button from step 4, you may skip to step 13 at this point. If you forgot to do so, or if you can't remember where you wrote it down, we now need to manually find out where Python was installed. It most likely got installed in C:\Users\<username>\AppData\Local\Programs\Python\Python36, by default, but we can find out for sure.

      Keeping the Environment Variables window and Edit environment variable dialog still open, open the start menu and check 'Recently Added' section at the top. You should see some Python utilities that just got installed. Right-click one of them, and More, then Open file location.

    11. This will open up a Windows Explorer to the location that holds the Start Menu shortcut for Python, but that's not where Python is actually installed. So we right-click the shortcut again, and click Open file location one more time.


    12. Now, we should be at the location of Python installation. Right-click on the path/address bar at the top of the window, then copy the full path.


    13. On Edit environment variables dialog, click 'New,' then type or paste in the full path of Python installation (the full path will most likely start with C:\ ... and end with ...\Python36).


    14. Verify that your entry is now part of the table, then click OK on Edit environment variable dialog, then OK on Environment Variables window, and finally OK again on System Properties window.


    15. Now, we will install Git (and along comes Git Bash). Open (run) the executable file for Git Installer.


    16. Once the installer is open, keep clicking Nextkeeping all options in the default configuration. When you reach the last screen, check the box marked 'Enable symbolic links' at the bottom, then click 'Install.'


    17. Once the installation is complete, check the box marked 'Launch Git Bash,' so we can check if Python is functional in Git Bash. Click 'Finish.'


    18. Git Bash should open automatically. Try typing python once it loads (shows the prompt ending in $). If nothing happens for a while (with no error messages or any other output), press Ctrl + C to stop the command.


    19. For some reason, entering python is not enough to fire up the Interactive Mode in Git Bash. Now try typing in python -i (dash i, for interactive) at the prompt. At this point, you should be able to see Python Interactive mode launch. Verify the version number is as expected (3.6.4 at the time of writing), and the prompt chevron (>>>) shows up.


    20. Type exit() in Python Interactive mode to terminate the Interactive mode and exit out to Git Bash. Try creating a Python script (using the text editor of your choice; in the example below, I used vim to create hi.py on my Desktop folder). Once your script is saved, you should be able to run your script by typing python <name of your script>.


    Congratulations! You have successfully installed Python and Git Bash on your Windows machine.

    If you're still encountering any problem with installing or running Python and Git Bash, please feel free to contact your instructor for additional help.



    Related Content