How to Install Python

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?

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.

How can I install Python on my computer?

There are different ways to install Python depending on your operating system. Here are some general steps:
1) Go to the official Python website (https://www.python.org/downloads/).
2) Click on the Download button for the latest stable version of Python.
3) Choose the appropriate installer for your operating system (Windows, macOS, or Linux).
4) Run the installer and follow the prompts to complete the installation.

What version of Python should I install?

It depends on your needs and compatibility with the libraries and tools you plan to use. The latest stable version of Python as of March 2023 is 3.10.2, but you may also need to install an earlier version if your code relies on specific features or modules that are not compatible with the latest version.

Do I need administrative privileges to install Python?

It depends on your operating system and the location where you want to install Python. On Windows, you may need administrative privileges to install Python system-wide or in a restricted folder. On macOS and Linux, you can usually install Python in your home directory without administrative privileges.

How can I check if Python is installed correctly?

After installation, you can open a terminal or command prompt and type “python” to start the Python interpreter. If Python is installed correctly, you should see the version number and the interactive prompt (“>>>”). You can also run a simple test script that prints “Hello, World!” to verify that Python is working:

print("Hello, World!")

Can I install Python on a USB drive or a portable device?

Yes, you can install Python on a USB drive or a portable device and run it from there. This is useful if you want to use Python on multiple computers or if you don’t have administrative privileges on the target computer. You can choose the “custom installation” option during installation and specify a different installation path. Then, you can copy the Python folder to your USB drive and run the “python.exe” file from there.

Do I need to install additional packages or libraries for Python?

It depends on your specific needs and the applications you want to build. Python comes with a standard library that provides many useful modules for common tasks such as file I/O, networking, and data processing. However, you may also need to install third-party packages or libraries that are not included in the standard library. You can use the “pip” package manager to install and manage packages from the Python Package Index (PyPI).