• Home
  • Linux
  • Ubuntu
  • Debian
  • CentOS
  • Linux Commands
  • About Us
  • Donate
TecNStuff
Menu
  • Home
  • Linux
  • Ubuntu
  • Debian
  • CentOS
  • Linux Commands
  • About Us
  • Donate

How to Install Python on Ubuntu 22.04

Written by Admin, Updated On January 19, 2023
python, ubuntu
How to Install Python 3.11 on Ubuntu 22.04

Python is popular programming language. It is used by multiple ways to build different kinds of applications. Python 3.11 is the latest major release of the Python language. It includes many new features such as new dict operators, new str functions, support for IANA time zone, and more. This tutorial describes multiple ways to install Python 3.11 on Ubuntu 22.04 system.

Install Python 3.11 on Ubuntu 22.04 using APT#

It’s very simple and straightforward process to install Python 3.11 on Ubuntu using the apt packages manager.

Perform the following steps to install Python on Ubuntu 22.04

Step 1 – Update packages list#

At first, update the packages list and install required dependencies:

sudo apt update
sudo apt install software-properties-common

Step 2 – Enable Repository#

After that add the deadsnakes PPA to your system’s sources list by typing:

sudo add-apt-repository ppa:deadsnakes/ppa

Hit the Enter when you get prompt.

Step 3 – Install Python 3.11#

Once the repository enabled you can install the Python 3.11 by running below command:

sudo apt update
sudo apt install python3.11

Step 4 – Verify Installation#

To verify the installation, you would type:

python3.11 --version
Python 3.11.0+

At this stage, the Python 3.11 is installed on your Ubuntu 22.04 system.

Install Python 3.11 on Ubuntu from Source#

You can install the latest version of Python and customize the build options by compiling the Python from source. Below are the steps to install Python 3.11 from Python source:

Step 1 – Install dependencies#

You should install the required dependencies to build python. Run the following commands:

sudo apt update
sudo apt install build-essential zlib1g-dev libncurses5-dev libgdbm-dev libnss3-dev libssl-dev libreadline-dev libffi-dev libsqlite3-dev wget libbz2-dev

Step 2 – Download source code#

After that download the latest source code from Python download page using wget:

wget https://www.python.org/ftp/python/3.11.0/Python-3.11.0.tgz

Once the download is finished, extract the gzipped archive:

tar -xf Python-3.11.0.tgz

Step 3 – Configure script#

Go to the Python source directory and execute the configure script. It will do few checks for dependencies.

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

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

Step 4 – Start build process#

You would run the following command to start the build process for python:

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.

Step 5 – Install Python#

Once the build process is complete, install the Python binaries by typing:

sudo make altinstall

That’s it. Python 3.11 has been installed from source and ready to be used. Verify the installation by typing:

python3.11 --version
Python 3.11.0

Conclusion#

This tutorial shows you multiple ways to install Python 3.11 on Ubuntu 22.04 system. You can read here How to use Pip.

If you have any questions or feedback, leave a comment below.

If our content helps you, please consider buying us a coffee

Thank you for your support.

Share On
Share on Facebook
Share on Twitter
Share on Reddit
Share on Tumblr
 Previous Article How to Install PHP 8.2 on Ubuntu 22.04
Next Article   How to Install PostgreSQL on Debian 11

Related Posts

  • How to Install Apache, MySQL, PHP (LAMP) on Ubuntu 22.04

    How to Install LAMP on Ubuntu 22.04

    March 20, 2023
  • How to Install LEMP Stack on Ubuntu 22.04

    How to Install LEMP Stack on Ubuntu 22.04

    March 18, 2023
  • How to Install Memcached on Ubuntu 22.04

    How to Install Memcached on Ubuntu 22.04

    March 16, 2023

Leave a Reply Cancel reply

DigitalOcean Referral Badge

Popular Posts

  • How to Install Microsoft Edge Browser on Ubuntu 22.04
    How to Install Microsoft Edge Browser on Ubuntu 22.04 March 14, 2023
  • How to Install Ruby on Ubuntu 22.04 LTS
    How to Install Ruby on Ubuntu 22.04 LTS February 27, 2023
  • How to Install LEMP Stack on Ubuntu 22.04
    How to Install LEMP Stack on Ubuntu 22.04 March 18, 2023
  • How to Install Set Up Apache Virtual Hosts on Ubuntu 22.04
    How to Set Up Apache Virtual Hosts on Ubuntu 22.04 March 2, 2023
  • How to Install MariaDB on Debian 11 Bullseye
    How to Install MariaDB on Debian 11 Bullseye March 8, 2023
© 2020 TecNStuff All rights reserved. This website is using and storing cookies on your browser. By using this website you agree our Privacy Policy.  Follow us -  Twitter | Facebook