Python Installation Guide, Install Python on Linux, Install Python on Mac

Step wise Guide to install python in just 5 mins | Python made Easy

Hello and welcome back to another exciting tutorial on "Python Installation". In this tutorial, you'll get a glimpse of "Installing Python on different platform" such as Windows, Mac or Linux. Let's begin our "Install python on any platform" with Python Installation on Windows.

Table of Contents

Installing python is like installing any other software. But, you should pick the compatible version of Python. The python installation tutorial begins with “Install Python on Windows” followed by “Install Python on Linux” and “Install Python on Mac”. Finally, in the end, you’ll learn how to install Python on IOS and Android platforms.

If you are completely new to python and wanted to deep dive in the python journey then check here to understand python is for you or not.

Python 2 has been downgraded since 1 January 2020.
We would install and code in python 3.x version( as of now 3.8) in this series.

Let’s begin our “Install python on any platform” with Python Installation on Windows.

Install Python on Windows.

Microsoft Windows, the most popular operating system don’t have pre-installed Python. But, you can install python on windows like any other application or software. The most stable python release is 3.8.3.
Python 3.8.3 doesn’t work on previous version of Windows (i.e. XP or earlier).

Downloading python-3.8.5.exe file

Step 1 – Visit the official Python download page here. Hover, cursor over the download menu option and then click on the Python 3.8.5 button to begin download.

Python-install-home
Python.org - Home Page

Important point: Hover over the Download section and click on Windows.

Step 2 – A new page will open which contains all the binary releases of python 2 and python 3. Select python versions (as of now it is python 3.8.3).

Python releases for windows.
Python releases for Microsoft Windows.
Step 3:- Click on (Download Windows x86-64 executable installer (26 MB of size)).

Installation

Step 1:- Click on the executable installer and grant administrative access to the program. A window like this or similar will appear.

Python Installer page
Python Installer page

Step 2:- Choose the Customize installation if you want to change something otherwise follow the instruction.

Check in the box which says Add python to the Path.

Step 3:- It will take 2 -3 minutes to install and a screen indicating installation successful will appear. If any error occurred you can write to me in the comment section,I will definitely try to help you.

Python Installation Successful
Python Installation Successful

Setup and Verification

Step – You can verify the python installation and its version by using following command.

  • python –version
Install Python on Linux , cmd screenshot
Install Python on Windows - cmd screenshot

Step – Run your first python script

  • On command line

Type python on command line and press enter. A python interpreter will open and now you can write python script in it. Refer following python interpreter screen shot. Type exit() to close the python interpreter.

Install Python on Linux , cmd python code
Install Python on Windows - cmd python code
  • Write python script in any text editor like Notepad and save it with .py extension and run in cmd using command.

python filename.py

First change the directory to the directory where you saved your file.

Program
Previous slide
Next slide

Install Python on Linux.

In contrast to Microsoft Windows, Python comes pre-installed in most Linux distributions. Linux system would have Python 2 by default. Moreover, you need to upgrade to Python 3.

The following terminal commands can be used to confirm the installation of Python on the Linux system. If you don’t get any command result, then you need to download and install python on linux machine. 

$ python --version
Python 2.7.17
$ python3 --version
Python 3.6.9

1.Ubuntu

Open the terminal using Ctrl + Alt + T .

Step 1:- First update the repositories by using the command.

$ sudo apt-get update

Step 2:- Add Deadsnakes Repositories.

$ sudo apt-get install software-proprerties-common
$ sudo add-apt-repository ppa:deadsnakes/ppa

Step 3:- Perform Step 1

Step 4:- Install Python

$ sudo apt-get install python3.8

Step 5:- Now, run the below command

$ python --version

Change default python version

  • The above command may show you python 2.x version as it is default python version. To change it ,follow the commands.
$ sudo nano ~/.bashrc
  • At the end of the file, append the following line.
alias python=python3.8
  • Save the file and run the below command in terminal.
$ sudo source ~/.bashrc
  • Now run
$ python --version

It will show you the current version as of now python 3.8.3

2. Compiling from Source

Downloading

Step 1:- Visit the official python download page here .

Step 2:- Hover over download section and click on Source Code

Step 3:- Download Gzipped source Tarball for the latest python 3.x release.

Preparation

Choose apt-get (like debian,ubuntu,mint) or yum( like centOS ) as per your linux distribution.
Step 1:- Update packages and repositories.
$ sudo apt-get update
$ sudo apt-get upgrade
Step 2:- Download necessary tools
# For apt based ditros
$ sudo apt-get install -y make build-essential libssl-dev zlib1g-dev libbz2-dev libreadline-dev libsqlite3-dev wget curl llvm libncurses5-dev  libncursesw5-dev xz-utils tk-dev
# For yum based distros
$ sudo yum -y groupinstall development
$ sudo yum -y install zlib-devel

Building from scratch

Step – Extract the downloaded tar file.

$ tar xvf filename.tgz
$ cd filename

Step – Prepare the build.

$ ./configure --enable-optimizations --with-ensurepip=install

Step – Start Building

$ make -j 8

Step – Install the latest version python

$ sudo make altinstall

If you don’t use altinstall , it will overwrite the system preinstalled version.

Step 5:- Step 5:- Check if everything goes right

$ python3 --version

Install python on Mac.

In contrast to Microsoft Windows, Apple MAC has a preinstalled Python 2.x version. You need to upgrade your machine to the latest version of Python 3.8.5. To download Python 3.8.5 click here and follow below steps to install python on Mac.

After clicking the link :-

Step 1 – Hover over Download Section and select Mac OS X

Step 2 – On next screen, Download the macOS 64- bit installer for the latest Python 3 versions.

Step 3 – Install the package and follow the instructions during the installation process.

After a successful installation, a directory with name python 3.x will be created in your application folder.

Change default python version

If you run the following command

$ python --version

It will result in something python 2.x version and not to the latest one you just installed. To change it to the latest one, follow these steps.

Step 1:- Open bash_profile

$ nano ~./bash_profile 

Step 2:- Add the line at the end of the file and save the file.

alias python=python3.8

Step 3:- Restart the terminal and run the python version command again. Now you will see the latest version of the python

Install python on IOS.

As per official documentation,there are two application to run python script on ios.

  • Pythonista
  • Pyto
Previous slide
Next slide

If you find any other application fascinating, feel free to ping me in comment section.

Install python on Android.

There are many apps on play store which provide linux environment .Pydroid 3 – IDE for python is the one.
You can import pandas, numpy, matplotlib and many more modules within your phone with this app.
pydroid home
Install python on Android
Open the app , you will see a black screen i.e. the editor where you write python script.
Click on the yellow colored floating button, a new screen with your output will appear.
Program
Output
Previous slide
Next slide

Online Editors.

You can check out some online editors like

There are more online code editors like these .You can run some python command on these platforms.

Conclusion

Finally, at the end a quick recap of what we learned in today’s python installation tutorial. You learn, how to download and install python on windows, Linux, and Mac machines. You also learn how to check the pre-installed version of Python in the case of a Linux or Mac machine. Last but not the least, do leave your feedback and suggestions. We would love to hear your feedback.