Installing Python On Your System

in STEMGeeks3 months ago

Our last post was more about why you should be using Python, with this post covering the finer details of how to install Python onto your system.

Not everything about learning Python is glamorous and this is probably one of the least glamorous things you'll do is install Python. The following post is basically about installing Python onto your system. It's pretty simple and we'll go through the installation for Windows, Mac and Linux systems.

Version of Python?


A lot of operating systems may have python already installed in them and if your computer does, that's cool but make sure it is running at least version 3 or higher. Version 2.7 may be needed by some operating systems to run specific applications but it is no longer supported and any up to date information or tutorials will most likely no longer be using these older version as well.

You'll probably need about 25Mb of disk space to install Python onto your system, but this is usually not a problem these days, so the footprint Python leaves on your system will not really be noticeable.

Python Is An Interpreted Language


Python is an interpreted language, compared to other languages like Java and C++ which are compiled languages. As an interpreted language, this means that each statement of code you write in the code is interpreted one by one when the program is run and turned into a language that is understood by the processor you are using. This is compared to a compiled language where the entire program is compiled and the code is executed in it's entirety and all possible errors are listed at compile time. When a Python program is run, it will only show the first error that makes the code fail, even though there may be multiple errors in the code.

This makes execution of Python code a little slower than compiled languages as the interpreter basically performing both error checking, converting the language into machine code and the running the program all in the same go.

When you install Python onto your system, you will also get the Idle interactive interpreter which allows you to type a command and allow to see the result of the code straight away. It's a good way to learn and test your code before implementing it into a program. Installations of Python may also come with Pip which is a package manager for Python and allows you to install extra libraries and modules onto your system. You should see this installed on your system automatically when installed onto Windows, but may need to install this onto your system if you are using Linux or Mac. You may not need this until later on after you have started programming.

Installing Python on Windows


There's a two ways you can install on a Windows system, so choose the method easiest for you.

1. Install from the Windows Store
One of the easiest places to start with a Windows installation of Python is by using the Windows Store where you'll find a large number of Python versions available, and don't worry there pretty much all free. Simply click on the version you need, download and then install on your device.

The installation from the Windows Store will Python, Pip, Idle and the documentation.

2. The Windows Python Installer
Python also provides a simple to use installer from the following download link:
https://www.python.org/downloads/

Once again choose the version you want to install and follow the prompts from the installer. Make sure you select the "Add python to path checkbox" so you'll be able to run Python from the command line.

The verify you have Python installed on your system, open Powershell and type py in the command prompt and this should start the Python interactive interpreter on your system. You should see an output similar to the one below:

py
Python 3.9.1 (tags/v3.9.1:1e5d33e, Dec  7 2020, 17:08:21) [MSC v.1927 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.                                                  >>> quit() 

You can also run Idle pretty simply by clicking the Windows key and then typing Idle in the search box.

Installing Python on Mac


If you didn't know already Mac is pretty similar to Unix or Linux systems and your system might already have Python installed on your system.

Before you start installing, it's probably best to check if Python is already installed on your Mac.

# Check the system Python version
$ python --version

# Check the Python 2 version
$ python2 --version

# Check the Python 3 version
$ python3 --version

If you don't have Python installed already and need to install it, the easiest way to go on Mac is using Brew. Open a terminal on your Mac and run the following command:

$ brew install python

Python also provides an installer similar to the one provided for Windows. You can use the same link provided above.

Installing Python on Linux


Python an Linux usually go hand in hand and if you are using Linux there's usually a good chance Python might be installed on your system already. You may need to have a smaller system running and it may not be installed, so the following details are for you, and as you'll see, just like Windows and Mac, its pretty simply to install.

Access a terminal screen

# debian/ubuntu
$ sudo apt-get update
$ sudo apt-get install python3

# Red Hat/CentOS
sudo yum install python3 -y

Thats about all there is to it...I admit not the most glamours post but they'll be more coming soon.

Found this post useful? Kindly tap the up vote button below! :)

About The Author


I am a DevOps Engineer, Endurance Athlete and Author. As a DevOps Engineer I specialize in Linux and Open Source Applications. Particularly interested in Search Marketing and Analytic’s, and is currently developing my skills in devops, continuous integration, security, and development(Python).

Posted with STEMGeeks