[email protected]Support 24/7 · Billing 09:00 – 00:00LinkedInXFacebook
NexonHost
Netherlands Dedicated ServersAmsterdam · Equinix AM6Germany Dedicated ServersFrankfurt · Equinix FR4Romania Dedicated ServersBucharest · VoxilityAustria Dedicated ServersVienna · Interxion VIEBulgaria Dedicated ServersSofia · TelepointFrance Dedicated ServersParis · Interxion PAR — Marseille · Digital Realty MRS3Ireland Dedicated ServersDublin · Equinix DB2Italy Dedicated ServersMilan · Irideos AvalonPoland Dedicated ServersWarsawSpain Dedicated ServersMadrid · Equinix MD2United States Dedicated ServersAshburn · Equinix DC
All articles
Getting startedJuly 10, 2023

How to install python on ubuntu 22.

How To Install Python On Ubuntu 22.

This article will explain how to build Python from the source code on Ubuntu 22.04.

Python 3 comes preinstalled by default on Ubuntu 22.04. To check the Python version installed on your system, type:

python3 --version

The output should look something like the below:

Python 3.10.6

If you need another or multiple Python versions installed on your system, you should build it from the source.

 

Installing Python on Ubuntu from Source

Compiling Python from the source allows you to install the latest Python version and customize the build options. However, you won’t be able to maintain your Python installation through the apt package manager.

At the time of writing this article, the most recent version of the latest major release of Python is 3.11. This version includes many speed improvements and new features such as new standards library modules, new syntax and built-in features, and more .

The following steps explain how to compile Python 3.11 from the source. If installing a newer release, change the version number in the commands below.

  1. First, install the libraries and dependencies necessary to build Python:

    sudo apt updatesudo apt install build-essential zlib1g-dev libncurses5-dev libgdbm-dev libnss3-dev libssl-dev libreadline-dev libffi-dev libsqlite3-dev wget libbz2-dev
  2. Download the latest release’s source code from the Python download page using the wget command:

    wget https://www.python.org/ftp/python/3.11.3/Python-3.11.3.tgz
  3. Once the download is finished, extract the archive :

    tar -xf Python-3.11.3.tgz
  4. Navigate to the Python source directory and run the configure command. This script performs a number of checks to make sure all of the dependencies are present on your system:

    cd Python-3.11.3./configure --enable-optimizations

    The –enable-optimizations option optimizes the Python binary by running multiple tests. This makes the build process slower.

  5. Start the build process:

    make -j 12

    For faster build time, modify the -j to correspond to the number of cores in your processor. You can find the number by typing nproc.

  6. When the build process is complete, install the Python binaries by typing:

    sudo make altinstall

    We’re using altinstall instead of install because the later command will overwrite the default system python3 binary.

That’s it. The latest Python has been installed on your system and is ready to be used by executing python3.11. To verify it, type:

python3.11 --version

The output will show the Python version:

Python 3.11.3

To use the default distro version, run python3.

Conclusion

We’ve shown you how to build Python from the source on your 22.04 machine. You can now start developing your Python project.

Keep reading
How to understand Bash Heredoc.
May 5, 2023

How to understand Bash Heredoc.

How To Understand Bash Heredoc. When writing shell scripts you may be in a situation where you need to pass a multiline block of text or code to an interactive command, such as tee , cat, or sftp . In Bash and other shells like Zsh, a Here document (Heredoc) is a type of redirection…

Read article
How to Create a File in Linux.
May 5, 2023

How to Create a File in Linux.

How To Create A File In Linux. In this tutorial, we’ll show you various ways to quickly create a new file in Linux using the command line. Knowing how to create a new file is an important skill for anyone using Linux on a regular basis. You can create a new file either from the…

Read article
How to use SSHFS to Mount Remote Directories over SSH
May 5, 2023

How to use SSHFS to Mount Remote Directories over SSH

How To Use SSHFS To Mount Remote Directories Over SSH This tutorial will show you how to install the SSHFS client on Linux, macOS, and Windows and how to mount a remote directory. SSHFS (SSH Filesystem) is a filesystem client based on FUSE for mounting remote directories over an SSH connection.…

Read article
Get in Touch

Together, Let’s Build a Faster, Safer Internet.

Build scalable infrastructure with NexonHost — high-performance dedicated servers, VPS hosting, cloud hosting, and DDoS protection across Europe.

Get Started →Contact Us
[email protected]Support 24/7 · Billing 09:00 – 00:00