How do i download python in linux terminal?

How do i download python in linux terminal?

This document describes how to install Python 3.6 or 3.8 on Ubuntu Linux machines.

To see which version of Python 3 you have installed, open a command prompt and run

If you are using Ubuntu 16.10 or newer, then you can easily install Python 3.6 with the following commands:

$ sudo apt-get update
$ sudo apt-get install python3.6

If you’re using another version of Ubuntu (e.g. the latest LTS release) or you want to use a more current Python, we recommend using the deadsnakes PPA to install Python 3.8:

$ sudo apt-get install software-properties-common
$ sudo add-apt-repository ppa:deadsnakes/ppa
$ sudo apt-get update
$ sudo apt-get install python3.8

If you are using other Linux distribution, chances are you already have Python 3 pre-installed as well. If not, use your distribution’s package manager. For example on Fedora, you would use dnf:

$ sudo dnf install python3

Note that if the version of the python3 package is not recent enough for you, there may be ways of installing more recent versions as well, depending on you distribution. For example installing the python3.9 package on Fedora 32 to get Python 3.9. If you are a Fedora user, you might want to read about multiple Python versions available in Fedora.

Working with Python 3¶

At this point, you may have system Python 2.7 available as well.

This might launch the Python 2 interpreter.

This will always launch the Python 3 interpreter.

Pipenv & Virtual Environments¶

The next step is to install Pipenv, so you can install dependencies and manage virtual environments.

A Virtual Environment is a tool to keep the dependencies required by different projects in separate places, by creating virtual Python environments for them. It solves the “Project X depends on version 1.x but, Project Y needs 4.x” dilemma, and keeps your global site-packages directory clean and manageable.

For example, you can work on a project which requires Django 1.10 while also maintaining a project which requires Django 1.8.

So, onward! To the Pipenv & Virtual Environments docs!


This page is a remixed version of another guide, which is available under the same license.

Python is now the most popular, most used programming language. Python's simple syntax and low learning curve make it the ultimate choice for beginners as well as professional developers. Python is also a very versatile programming language. It's used nearly everywhere—from web development to artificial intelligence—really anywhere other than mobile development.

If you're using Python, there's a good chance you're a developer (or want to become one), and Linux is a great platform for creating software. But when you're working with Python every day, you sometimes want to stay up to date with the very latest version. You may not want to replace the default install of Python on your system just to test drive the latest one, so this article explains how to install the latest version of Python 3 on Linux without replacing the version provided by your distribution.

Use the python --version terminal command to check whether Python is already installed and, if so, which version you have. If Python is not installed on your Linux system, or you want to install an updated version, follow the steps below.

Step-by-step installation instructions

Step 1: First, install development packages required to build Python.

On Debian:

$ sudo apt update
$ sudo apt install build-essential zlib1g-dev \
libncurses5-dev libgdbm-dev libnss3-dev \
libssl-dev libreadline-dev libffi-dev curl

On Fedora:

$ sudo dnf groupinstall development

Step 2: Download the stable latest release of Python 3

Visit the official Python website and download the latest version of Python 3. After the download is complete, you hav a .tar.xz archive file (a "tarball") containing the source code of Python.

Once the download is complete, extract the tarball by either using the extractor application of your choice or the Linux tar command, for example:

$ tar -xf Python-3.?.?.tar.xz

Step 4: Configure the script

Once the Python tarball has been extracted, navigate to the configure script and execute it in your Linux terminal with:

$ cd Python-3.*
./configure

The configuration may take some time. Wait until it is successfully finishes before proceeding.

Step 5: Start the build process

If you already have a version of Python installed on your system and you want to install the new version alongside it, use this command:

$ sudo make altinstall

The build process may take some time.

If you want to replace your current version of Python with this new version, you should uninstall your current Python package using your package manager (such as apt or dnf) and then install:

$ sudo make install

However, it's generally preferable to install software as a package (such as a .deb or .rpm file) so your system can track and update it for you. Because this article assumes the latest Python isn't yet packaged yet, though, you probably don't have that option. In that case, you can either install Python with altinstall as suggested, or rebuild an existing Python package using the latest source code. That's an advanced topic and specific to your distribution, so it's out of scope for this article.

Step 6: Verify the installation

If you haven't encountered any errors, the latest Python is now installed on your Linux system. To verify it, write one of these commands in your terminal:

python3 --version

or

python --version

If the output says Python 3.x, Python 3 has been successfully installed.

Create a virtual environment (optional)

Python provides a package known as venv (virtual environment), which helps you isolate a program directory or package from other ones.

To create a virtual environment, enter the following in the Python terminal (in this example, assume the version of Python you've installed is in the 3.8 series):

python3.8 -m venv example

This command creates a new directory (which I've named example), with some subdirectories.

To activate the virtual environment, enter:

$ source example/bin/activate
(example) $

Notice that your terminal prompt ($) is now preceeded by an environment name.

To deactivate the virtual environment, use the deactivate command:

(example) $ deactivate

Conclusion

Python is a fun language that's developed and improved frequently. Getting familiar with new features is easy, once you understand how to install the latest release without interfering with the stable version provided from your distribution.

If you have any feedback or questions, please leave them in the comments.

How do i download python in linux terminal?
This work is licensed under a Creative Commons Attribution-Share Alike 4.0 International License.

How do I install a Python terminal?

Install Python Using APT.
Open up your terminal by pressing Ctrl + Alt + T..
Update your local system's repository list by entering the following command: sudo apt update..
Download the latest version of Python: sudo apt install python3..
APT will automatically find the package and install it on your computer..

How do I install Python 3.7 from terminal?

Option 2: Install Python 3.7 From Source Code (Latest Version).
Step 1: Update Local Repositories. ... .
Step 2: Install Supporting Software. ... .
Step 3: Download the Latest Version of Python Source Code. ... .
Step 4: Extract Compressed Files. ... .
Step 5: Test System and Optimize Python. ... .
Step 6: Install a Second Instance of Python (recommended).

Can I get Python on Linux?

Python comes preinstalled on most Linux distributions, and is available as a package on all others. However there are certain features you might want to use that are not available on your distro's package. You can easily compile the latest version of Python from source.

How do I download Python 3.8 on Linux?

How to Install Python 3.8 on Ubuntu, Debian and LinuxMint.
Step 1 – Installing Prerequisite. As you are going to install Python 3.8 from the source. ... .
Step 2 – Download Python 3.8. Download Python source code using the following command from python official site. ... .
Step 3 – Compile Python Source. ... .
Step 4 – Check Python Version..