How to Install Python

by | Aug 31, 2021 | Python Programming

In this part, we will learn to set up and install python on our computer, and once we do that, we will be ready to run our first python program.

 

install Python

Python is available mainly on various platforms like Linux, Windows, Mac OS X, and embedded systems like Raspberry Pi.

So let’s set up python on our Computers.

How to install Python on Windows

 Step 1: To check if you have python installed on your Windows PC, we have to run Command prompt(cmd.exe) on Run Menu, which can be open Crlt + R.

Open CMD on Winodws

Step 3: After opening the cmd, we will type the following command to check if you have python installed.

C:\Users\Your Name >python --version

Output:

Python 3.9.1

 

CMD Screen

How to install Python on Windows computers

Step 1: To install python on windows, first, we have to download python from their official website: www.python.org/downloads and then click on Download Python. Maybe you will see a different python version, but you can download any newer version from 3.9.

Python Homepage

Step 2: Open the python file we downloaded. Suppose it asks for administrator permission press Yes.

Step 1 - Python Installation

Step 3:  Select the checkbox “Add Python 3.9 to PATH” option. You are free not to select it, but it may cause an issue in the future if you do not check it. Python community recommended it to select the checkbox.

Step 2 Python Installation

Step 4: Now click on Install Now, and if it asks for Administrator permission, press the Yes button, and then python will start installing on your computer.

Step 3 - Python Installation

Step 5:  You will see a message like “Setup was successful,” which means we have installed python on our Windows computer, then click on the Close button to close the python setup file.

Step 5 - Python Installation

How to install python on Linux

To check if python is installed on your Linux pc, we have to follow the same steps as above. Still, instead of opening CMD, we will open a terminal in Linux by pressing Alt + Clt + T on your keyboard, and in the terminal, type the following commands to check the python version.

python --version
Open Terminal Linux

The easiest way to run python:

The easiest and secure way to run python code is by using python IDLE.

Python IDLE is the official text editor provided by python. It is available along with python on windows platforms, but we need to install it separately on Linux.

Let’s install python and Python idle on the windows platform step by step. If python is not installed on your Windows computer, follow these steps.

It is straightforward to install python on a Linux computer; unlike windows, it has very few steps.

Step 1: Type the following command in the Linux terminal

sudo apt install python3

 

Install Python on Linux

As you see, python is already installed on my Linux computer. 

Check Python

But if python is not installed on your computer, you will see something like this.

Check Python Install

If it asks for a password, type it and hit enter. Then you will see something like this.

Now press Yes or just hint enter, and python3 will be installed on your computer.

How to run python on Linux?

Now let install python idle using the following command.

sudo apt install idle
Install IDLE

And follow the same process to install idle.

We have to search idle the same for Linux and windows by searching Idle on the start bar on windows and search bar in Linux to open idle.

To open idle on your computer, you can search “idle” on your respected operating system.

Below you can see the First look of Python IDLE.

IDLE Screen

Online Python Compiler / Interpreter

If you don’t want the hustle of installing python and other software on your computer, you can use our online python compiler/interpreter. It can run python code very smoothly. It is very easy to use for beginners, and if you don’t have a computer, you can also run it on your mobile phone through web browsers like Google Chrome or other web browsers.

Jupyter Notebook

The Jupyter Notebook is an open-source web IDE that allows you to create and share documents that contain live Python code, equations, visualizations, and narrative text. It is mainly used by beginners using python for data science because it provides a beautiful interface.

Install Jupyter Notebook on Linux

Same as python idle, we can install Jupyter notebook with the same steps as follow.

sudo apt install jupyter

To open Jupyter notebook, we have to type jupyter notebook on the Linux terminal.

Open Jupyter Notebook

Install Jupyter Notebook on Windows 

If you want to install a jupyter notebook on windows, we have to follow the same steps as installing python on a windows computer. Still, like Linux, we cannot install jupyter notebook on windows directly; it comes with Anaconda software, which is a powerful tool for learning Data Science, Machine learning, and Artificial intelligence.

We can also install anaconda in Linux as well as on Mac OS.

We can download anaconda from its official website. To download anaconda, click here.

Pycharm

Pycharm is the most popular and most used integrated development environment (IDE) used by most experienced developers. Pycharm has a Professional version that is not free, and a community version is a free community version giving the project name; click on creating a new pycharm project.

Pycharm will make a separate virtual environment for all the projects, which can be used to work with different versions of python libraries without affecting your system libraries.

There is a very different method to install Pycharm in Linux, and for Windows, it is the same steps to follow, just like we install python.

If any student with an academic email, which will be examplename@universityname.edu, can request to access the pycharm professional edition for free. For more information, vistheirere Educational Page.

Install Pycharm on Linux

To install pycharm on a Linux computer, we have to open the terminal and type the following command in the terminal.

sudo snap install pycharm-community --classic

The second method to install pycharm on a Linux computer is by downloading the pycharm package manually, which will be a tar.gz file.

Step 1: Go to the Pycharm Download page and download the Community version.

Step 2: Go to the path where you have downloaded the Pycharm file.

cd ~/Downloads

Step 3: Now, we have to extract the tar.gz file using the tar command.

tar -xzf cd pycharm-community-2020.3.2.3.2.tar.gz

Step 4: Now go to the extracted pycharm folder as follows.

cd pycharm-community-2020.3.2

Step 5: Now go to its bin folder inside the pycharm folder.

cd bin

Step 6: We have to make sure that the pycharm shell script has sufficient permission:

chmod u+x pycharm.sh

Step 7: Now run the shell script.

bash pycharm.sh

 

Pycharm IDE interface

Open Pycharm

There are many different kinds of IDE’s and interpreters which are used to compile and execute the python codes like Atom, Scite, and Spyder.

But if you’re a beginner python, IDLE and a jupyter notebook will be easier to run python code and your experience coder; you can go for pycharm or Atom. These IDEs will save more time than any other IDE’s for python.

How to install python modules?

In this step, we will learn about how we can install python modules on you system but let us  first know what is python modules.

What is a python module?

The python module is just a bunch of python files (.py) that contains codes and statement that can be used to import into an existing program to add functionality without writing large codes.

Python modules are also known as python packages and  python libraries.

How to install the python module or python library?

We can use the “pip” command to install the python modules in our python environments.

Example 1:

pip install Module_Name

Example 2:

python -m pip install Module_Name

Tips for beginners

  • Always use a simple interpreter to execute python codes.
  • Use Python3 newer version because mostly python2 comes preinstalled in many operating systems, but python2 is outdated.
  • Always make a separate virtual environment while working with pycharm.
  • Never Uninstall pre-install Python, which comes with many Operating systems; it is meant to crash your operating system.

FAQs

How to check if python is installed on Linux?

We can use the built-in python command to check if python is installed on Linux or on Ubuntu. Use the below command to check whether python is installed or not.

python -V

If python is installed then it will print the installed version of python or it will return an error.

How to check if python is installed in Linux?

We can use the built-in python command to check if python is installed on Linux or on Ubuntu. Use the below command to check whether python is installed or not.

python -V

If python is installed then it will print the installed version of python or it will return an error.

How to check if python is installed on windows?

We can use the below command to check if python is installed or not on your windows system.

python -V
What is pip install python?

The pip stands for Package installer for python that’s is a free package manager tool to install python packages or python libraries in your python environment.

 

Was this article helpful?
Share on: