python programming - Installing python

15 Nov 2018 - Mark Edosa

Installation of python is very easy although it is dependent on the operating system of your device.

To install python, go to https://www.python.org/downloads/ and select the latest release of the python software based on your operating system. Usually, the download options specific to your operating system are shown first. This article is second in the introduction to python programming series. The first article that introduces the subject matter can be found here.

Installing python on Windows / MacOs

Click the orange-colored download button if you want the 32-bit version of the software (e.g. python-3.7.1.exe) else scroll down a bit and click on a specific release e.g. python-3.7.1. This should take you the page where you can select the 64 bit version of the software. This should be python-3.7.1.amd64.exe for example. (note the amd64)

Upon clicking the python executable or .exe file, you should get a prompt as shown below:

start prompt for python installation

Make sure you check the “add python to path” option as shown above. This enables you run the python interpreter from the commandline anywhere on your device. Also it makes it easier for other softwares which require python to find the python program.

Then click install now or click customize installation if you want specific features (both optional and advanced) as well as the ability to choose the location of installation. If you are a beginner, click install now. Note that you can make further modifications after installing python by clicking the installer. After a successful installation, you should see this.

python successful installation image

After installation, open the commandline on your device (shift + right-click) and type python or py or python3. This should launch the python interpreter.

python interpreter from the commandline

On windows only: py -0 to produce a list of the installed pythons, with default marked with an asterisk. Running py -0p will include the paths. If py is run with a version specifier that cannot be matched it will also print the short form list of available specifiers (excerpt from python 3.7 changelog)

Along with the python interpreter, other files associated with the python installation includes

  • the python manual/documentation (a must-have great place to learn python)

  • the default python shell called IDLE

  • the python module documentation

    click on this to open the module docs in your device’s default web browser. There you can assess information on python functions available in the modules

  • python text editor - not so fancy like jetbrains pycharm but can be useful in certain cases.

Installation on other operating systems

Installation on mac follows a similar process as explained above. On linux, python is installed by default. If you’d like to install a different version then run

  1. sudo apt-get update

  2. sudo apt-get install python-version

When you can’t run python from the commandline

If you do get the above message, do the following.

  • verify that the python software was properly installed; type python.exe in the search bar of your device. If found right-click and open folder location. You should see python.exe among other files.

  • if python.exe is available, most likely python wasn’t added to the path variable during installation. The easiest way to solve this problem is to click on the python installer (the file you downloaded) and choose the modify option. Then click next. Make sure the add python to environment variables option is checked and you are good to go.

modifying python installation

ensuring that the add python to path variable is checked

Conclusion.

As you make progress in the understanding and use of the python programming language, the ability to use python efficiently from the commandline is one skill you should possess especially if you want to be a system administrator or a devOps engineer. As a beginner you don’t have much to worry about…for now. If you have not installed an IDE Let’s take a look at python’s datatypes which is very essential for the creation of applications with python.

About author
Generic placeholder image
Mark Edosa

Mark Edosa is an Optometrist by day and a Web developer / Data scientist by night. At his spare time, he loves learning new stuffs as well as listening to music.