Python is a very popular programming language, and in order to learn this programming language, you first need to install Python on your system. There are some systems that come with Python already installed, but it is usually not installed on Windows operating system. However, if someone wants to install or update Python manually, you can follow this guide.
This guide will help you how you can install Python on different types of operating systems so that you can follow the installation steps based on whichever operating system you have.
How to install python on windows (10 and 11):
So, if you are a windows user, you only need to follow a couple of steps to install Python on Windows 10 or 11. These steps will help you to access Python from anywhere in the system and install additional packages or libraries of Python by using its package manager. The following steps will help you to install Python on windows 10 or 11:
- Open any browser on your system and go to the Python website using this link: https://www.python.org/downloads/
- It would be best if you chose the Windows option from the menu, and you’ll have to click on the download button, usually named the latest version of Python.
- After successfully downloading Python, open the file and install it in the windows installer. You need to make sure you select “Install launcher for all users (recommended)” and the other “Add Python 3.11.1 to PATH”. These options are mandatory to be chosen in order to use python from anywhere in the system.
- Now, after successful installation, you will see a message from the installer, “Setup was successful,” that you can close and open Python IDLE by searching it in the Start menu.
How to install python on MAC
Python 2.7 is already installed on macOS by default, but in case you need to install the latest version of Python, then you need to follow these steps:
- First, check the current Python version of your system. For that purpose, you need to open the terminal, write “python –version,” and press ENTER, which will return the Python Version on your Mac Device.
- Now, to install the latest version of Python on your system, go to the address: https://www.python.org/downloads/ and choose macOS as your operating system and download the .pkg file from there.
- Now, to install python, open the download .pkg file on your mac system and follow the steps of installation.
Here, you need to click on Continue a few times, and you will see an install button later, as shown in the image below:
- After pressing the install button, it will ask you for the system password before starting the installation, as shown in the image below:
- After entering the password, click “Install Software,” and it will start installing the latest version of python. You can verify the installation using the same command we initially used to check the Python version.
To verify the latest version of Python on your system, use the command – “python3.11 –version” on the Terminal, which will show like this:
How to install python on Ubuntu
Python already comes installed on Linux distribution, but sometimes, you might not find it already installed on Ubuntu systems. In those situations, you can install Python in various ways. In this guide, we are going to install python using APT (Advanced Package Tool), which is a default package manager on Ubuntu. See the following steps to install Python on Ubuntu:
- Open the terminal on Ubuntu by pressing these keys simultaneously: Ctrl + Alt + T
- Now type the following command on Terminal to enter the system’s repository:
- sudo apt update
- Now you need to use the “Sudo apt install python3” command to install python on Ubuntu.
- After that, APT will find the installer package automatically and install Python on your system.
How to install python on Linux
As we just discussed that python already comes installed on Linux systems, but in some cases, if you want to install Python on your system manually, then follow the steps below:
- Download and install the development packages that are required as prerequisites to install Python on Debian and Fedora. You need to use the following command on your terminal to install the necessary development dependencies:
- sudo apt-get build-dep python3
- Now, after you have successfully installed these packages, you need to download the latest version of Python from the address: https://www.python.org/downloads/, and you need to be specific for your system, such that for Linux.
- Now, you can simply extract the tar file to install Python on Linux and finish the installation with some common configurations and commands on your terminal:
- tar -xf archive.tar.xz
- Please note, in some cases, the name becomes different for the downloaded file for example: “python-3.11.2.tar.xz”. So, it would be best if you used the exact same name while extracting the downloaded file.
- As a last step, you need to verify the installation whether it is successful or not with any code or text editor. You can open any editor and create a new python file with the following code:
print(“Successfully Installed”)
And save this code with the name – “test.py”
Now, to check if the code is working or not, you need to open the terminal and go to the directory where you saved this python file. Run the file using the following command:
“python test.py”
The output should be :
Successfully installed
And this means that python is working on your Linux system and installed successfully.
How to install python pandas
There are different ways to install Python Pandas on different operating systems such as Windows, Linux or macOS.
For Windows:
Open Command Prompt and use the following command:
“pip install pandas”
For Linux:
Open the terminal and use the following command to install Pandas on Linux:
“sudo apt install python3-pip”
This will install the python package installer and then you can follow the next step:
“pip3 install pandas”
For macOS:
- Check if pip and python3 are already installed on your system. To do that, open the terminal and use these commands:
python3 –version
pip –version
As you can see python and pip are already installed and updated on the device.
- Now, if these things work well, then you can just use this command to install pandas:
“pip3 install pandas”. If not, then please download and install PIP and Python on your macOS. Please refer to the screenshot below:
How to install matplotlib in python
Before installing Matplotlib on your system, you need to check if Python and PIP manager is already installed on your OS or not. You can use the following command to check Python’s current version on your system.
“python –version”
To check the pip version:
“pip –v”
Now, to install matplotlib on Windows, Linux and macOS, use the command below only if you already have installed pip and python on your system:
“pip install matplotlib”
How to install NumPy in python
In the case of the Windows operating system, Python doesn’t come already installed. Therefore, first, you need to install Python and then you can install the Numpy library on your device. We already discussed how you can install Python on your system and you can follow the steps described in this article. Later you need to follow these steps for installing Numpy:
Open Command Prompt and run the following command:
“pip3 install NumPy”
This will install Numpy on your Windows operating system.
For mac devices, you need to run this command in the terminal:
“pip install NumPy”
As you can see that it is showing requirement is already satisfied which is because I already installed NumPy on my system. But in your case, it will start the installation.
For Ubuntu operating systems, you need to open Terminal on your device and run the below command:
“apt install python-pip python-pip3”
This command will install the pip (Pip installs packages) device and then you can install Numpy on your system using the command given below:
“pip3 install numpy”
How to install OpenCV in python
In order to install the OpenCV library on your device, Python and PIP should be preinstalled on your system and then you can install OpenCV on your device without any problem.
For Windows OS, use the following command in Command Prompt to install OpenCV on your device:
“pip install OpenCV-python”
Now this will install OpenCV on your device and you can use this library by simply importing it into the command line. You can use the following commands to use this library:
Just write Python3 in your command prompt and press Enter. Now you need to import OpenCV with the help of the “import cv2” command. After that, you can use this library accordingly.
For Ubuntu systems, you can also use pip3 to install OpenCV. Just run the following command on the Terminal that will install OpenCV on your ubuntu device:
“pip3 install OpenCV-python”
For macOS, the command given below will install the OpenCV package on your mac devices:
“pip3 install OpenCV-python”
How to install packages in python
Various Python packages are now made in a way that they can be installed directly with the help of Python’s pip package manager. However, there are multiple ways to install packages in Python on different operating systems. But, here we will discuss a very simple way i.e. pip package manager. Some packages are not compatible with pip, but you can install those packages manually.
First, let’s see how you can install Python’s pip package manager on your system:
For Windows OS:
- Run Command Prompt and use the following command to download the pip file for installation:
“curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py”
- Now you have to install the downloaded file using Python. To do that, run the following command:
“python get-pip.py”
- Lastly, to verify the installation, you have to write – “pip help” on your command prompt which will show some description which means that the pip manager is successfully installed on your device.
- The Last step after installation is to add Pip to windows environment variables with the help of the following steps:
* Open Control Panel and then go to System and Security.
* Find System Setting and navigate to it.
* Now on the right side of the window, you may see Advanced System Settings which will take you to Environment Variables.
* In the Environment Variables window, you need to click on Path and then click New where you need to give the path of the installed Pip directory.
* Lastly, click OK which will save the path for environment variables.
PIP For macOS:
Open Terminal and download pip by running the command given below:
“curl https://bootstrap.pypa.io/get-pip/py -o get-pip.py”
This command allows you to download the pip package manager on your mac device. After successful installation, you can use pip manager to install any package on your system.
PIP For Ubuntu:
You need to install pip first to install packages of Python. PIP can be installed using the following command:
“sudo apt-get -y install python3-pip”
After the successful installation of PIP, you can also verify its version by using the command:
pip3 –version
How to install the python module
Python modules can be installed with the help of python-pip. For example, you can simply write the command – “pip install hashlib” to install the hashlib library of python. So, you need pip to install python modules on your system. The next section will guide you on how you can install Python pip on your system.
How to install python PIP
PIP stands for PIP Installs Package which means PIP is itself a package that can be used to install python packages. Now, for installation of Python PIP, you can follow the guide given below:
For Windows OS, open the command prompt and run the following command:
“curl https://bootstrap.pypa.io/get-pip/py -o get-pip.py”
Now, this command will install python-pip and you can use it for installing python packages.
For macOS, open Terminal and run the following command:
“curl https://bootstrap.pypa.io/get-pip/py -o get-pip.py”
For Ubuntu, open Terminal and run the command given below:
“sudo apt-get -y install python3-pip”