In the previous article, I have described all the steps to be followed to install Python on Windows system. In this article, I am sharing all the commands you should run to install Python on Linux, including various Linux distributions.
In this tutorial, I will be covering installation of both versions.
To update you, many of the giant companies are moving to Python 3. In recent, Instagram is migrated from Python 2 to Python 3, successfully.
Now follow the steps of the Installing Python 3.4 and PIP for Python 3.4 section of the article above. Python 3.6 should be installed along with PIP for Python 3.6. Python 3.6 should be installed along with PIP for Python 3.6. Installing Python 3, type: $ sudo apt-get update $ sudo apt-get install python3-pip python3-dev nginx Create a Python 3 Virtual Environment. Next, we'll set up a virtual environment in order to isolate our Flask application from the other Python files on the system. Start by installing the virtualenv package using pip. If you are using Python 3, type: sudo pip3 install virtualenv. Now, we can make a parent directory for our Flask project. The vast majority of CentOS/RHEL-based Linux servers use Python 2.6.6, while most of my Python applications are written in Python 3. In additoin, on most of the servers, I don’t have the sudo priviledge, so it needs a little trick to install Python 3 on those servers. To install Python in these Linux distribution, Open terminal and run command those are given below. $ sudo apt-get update $ sudo apt-get install python3.6 If you want to install Python 2 version, run following commands.
So coming to installation…
You can download Python package from their official website. Or you can skip downloading it if you have internet connected to your Linux system where you want to install Python.
As we all know, there are various flavors of Linux such as Ubuntu, Fedora, Linux Mint, CentOS… And each one of the Linux distribution has a particular package manager.
Depending on the package manager, you need to follow commands to install Python on Linux.
Let’s see how to install Python on each Linux distribution, individually.
Install Python on Linux:
To install any package on Linux, you need to use specific command based on the package manager.
APT package manager – Debian / Ubuntu | Linux Mint Linux User
Ubuntu and Linux Mint distributions use APT for package management.
To install Python in these Linux distribution, Open terminal and run command those are given below.
If you want to install Python 2 version, run following commands…
Note: There can be multiple dependencies among packages installed on Linux. Make a habit of updating installed packages before installing any new package (First command mentioned above).
DNF Package Manager – Fedora Linux User
Install Python 3 On Linux Mint
Fedora have default DNF package manager for installing and managing packages in Linux.
Run following command in terminal.
Installing Python 3:
Installing Python 2:
It installs the latest Python version for both Python 3 and Python 2.
Yum Package Manager- Redhat / RHEL / CentOS Linux User
Redhat / RHEL / CentOS Linux User should run the following command to install Python.
If you are not root user, you should use sudo keyword every time installing Python package on your Linux system.
Meanwhile, you can have coffee for you as it may take some time to install.
That’s all!
You installed Python successfully.
Interestingly, you can download both Python 2 and Python 3 version on your single system. Wire.h library download.
Checking Installed Python:
Open Linux terminal and type…
It opens Python 2 version interpreter prompt.
It opens Python 3 version interpreter prompt.
You can write your Python code in Python interpreter prompt.
Do you want to check Python version installed on your system?
Run a command…
Writing Hello Wolrd Program on Python Prompt:
To test if the Python is working fine, write your first hello world program on Python interpreter prompt.
Output:
Wow! It is so easy.
To exit Python interpreter prompt, run following command.
and press Enter.
Related Read: How to Clear Python Interpreter Console?
What’s Next?
Now everything is setup to start harnessing Python skills. If you are eager to learn Python, follow Python tutorial from the beginning.
Remember…
You can not learn any programming language without making your hands dirty with the code.
To install Python on Linux system, you need to follow these commands. If you face any issue to install Python on Linux (Ubuntu or any Linux distribution) or any comment for this article, write in the comment section. Let’s connect with us.
All the Best!
Related Posts
In this article, I am going to explain how to install Python 3.6 on Linux using the terminal interface. But, before we proceed first let’s see what is Python and what is the use of Python. Python is an interpreted, object-oriented, high-level programming language with dynamic semantics. Its high-level built in data structures, combined with dynamic typing and dynamic binding, makes it very attractive for Rapid Application Development, as well as for use as a scripting or glue language to connect existing components together. Python is simple and easy to learn syntax emphasizes readability and therefore reduces the cost of program maintenance. Python supports modules and packages, which encourages program modularity and code reuse.
The Python interpreter and the extensive standard library are available in source or binary form without charge for all major platforms and can be freely distributed.
How To Install Python 3.6 on Linux Using Terminal Interface
To install Python 3.6 on Linux
Check to see if Python is already installed on your system:
If Python is not installed, install Python with your distribution’s package manager. The command and package name vary:
On Debian derivatives such as Ubuntu, use APT:
On Red Hat and derivatives, use yum:
On SUSE and derivatives, use zypper:
Also Read – How To Install PIP (Python Packages Management System) in Linux
Install python 3.6 on Linux (Ubuntu 18.04)
Before we proceed first let’s update old repositories to its current version.
Open the Terminal and execute the command “sudo apt-get update”
Also Read-
To Install Python 3.6 On Linux Download The Package
If you have not download Python yet then download the latest version of Python 3.6.5 package, Click here to download the Package.
Once download gets complete follow the steps to proceed further. You can verify this using terminal or graphical way.
Installing Python 3.6.5 package
Install Python 3 On Linux Azure
To proceed with installation first we have to extract the downloaded package by executing the following command on the terminal window.
As you can see in above package is extracted successfully. Let’s move on script configuration
Also Read-
Configuring Python 3.6.5 Script
Install Python 3 Windows
Open the Python-3.6.5 directory (extracted file) and use “configure” command to configure it.
Now you have successfully completed the script configuration.
Completing Python 3.6.5 Installation
To complete the installation process we will use the following commands:
sudo make
sudo make install
We have successfully installed the Python 3.6.5 package on Ubuntu 17.10. Open a command prompt or shell and run the following command to verify that Python installed correctly:
Install Python 3 On Linux Mint
Also Read-
Install Python 3 On Amazon Linux
This is how we can install python 3.6 on Linux. If you found this tutorial helpful then Like and Share. If you got something else then feel free to comment.