• About Us
  • Disclaimers
  • Privacy Policy
  • Sitemap
Linux Tutorials for Beginners
Advertisement
  • Ubuntu
    Install and Secure phpMyAdmin on Ubuntu 22.04

    How To Install and Secure phpMyAdmin on Ubuntu 22.04

    Secure SSH with Fail2Ban

    How To Secure SSH with Fail2Ban on Ubuntu 22.04

    Install Uptime Kuma on Ubuntu 22.04

    How To Install Uptime Kuma on Ubuntu 22.04

    Install Ubuntu Server 22.04

    How To Install Ubuntu Server 22.04 LTS with Screenshots

    Set Up Firewall on Ubuntu 22.04

    How To Set Up a Firewall with UFW on Ubuntu 22.04

    Install Nginx on Ubuntu

    How To Install Nginx on Ubuntu 22.04: A Comprehensive Guide

    Install MySQL 8.0 on Ubuntu 22.04

    How To Install MySQL 8.0 on Ubuntu Server 22.04

    install-php74-ubuntu2204

    How To Install PHP 7.4 on Ubuntu 22.04

    Install Snipe-IT on Ubuntu 22.04

    How To Install Snipe-IT Asset Management on Ubuntu 22.04

  • Debian
    Secure SSH with Fail2Ban

    How To Secure SSH with Fail2Ban on Debian 11

    Install Debian 11 Server

    How To Install Debian 11 (Bullseye) Server with Pictures

    Install and Setup Node.js on Debian 11

    How To Install and Setup Node.js on Debian 11

    Install PHP 8.2 on Debian 11

    How To Install PHP 8.2 on Debian 11

    Install Nginx on Debian 11

    How To Install Nginx on Debian 11: A Comprehensive Guide

    Set Up Firewall with UFW on Debian

    How To Set Up a Firewall with UFW on Debian 11

    install php74 on debian 11

    How To Install PHP 7.4 on Debian 11

    Install MariaDB 10.9 on Debian 11

    How To Install MariaDB 10.9 on Debian 11 Server

    Initial Setup Debian Server

    Initial Setup Debian 11 Server: Secure and Efficient

  • Rocky Linux
    Install phpMyAdmin on Rocky Linux 9

    How To Install phpMyAdmin on Rocky Linux 9

    Secure SSH with Fail2Ban

    How To Secure SSH with Fail2Ban on Rocky Linux 9

    Install Rocky Linux 9.2 Server

    How To Install Rocky Linux 9.2 Server with Screenshots

    setup Firewall Using Firewalld Rocky Linux 9

    How To Set Up a Firewall Using FirewallD on Rocky Linux 9

    Install Nginx on Rocky Linux 9

    How To Install Nginx on Rocky Linux 9: A Comprehensive Guide

    Install Apache on Rocky Linux

    How To Install and Configure Apache on Rocky Linux 9

    Install MongoDB on Rocky Linux 9

    How To Install MongoDB 6.0 on Rocky Linux 9

    Install Docker on Rocky Linux

    How To Install Docker CE on Rocky Linux 9

  • CentOS
    Secure SSH with Fail2Ban

    How To Secure SSH with Fail2Ban on CentOS 7

    Install PHP8.2 on CentOS 7

    How To Install PHP 8.2 on CentOS 7 / RHEL 7

    Install Apache on CentOS 7

    How To Install Apache Web Server on CentOS 7

    Set Up FirewallD on CentOS 7

    How To Set Up a Firewall Using FirewallD on CentOS 7

    Initial Setup CentOS 7 Server

    Initial Setup CentOS 7 Server: Secure and Efficient

    Install Nginx on CentOS 7

    How To Install Nginx on CentOS 7: A Comprehensive Guide

    Build NGINX from Source on Centos 7

    How To Build NGINX from Source (Compile) on Centos7

    Install Docker Swarm on CentOS 7

    Install and Configure Docker Swarm Mode on Centos 7

    Install Docker Compose on Centos 7

    How To Install and Use Docker Compose on Centos 7

  • Linux
    Manage Groups on Linux

    A Simple Guide: How To Manage Groups on Linux

    Logrotate In Linux

    How To Manage Log Files Using Logrotate In Linux

    Check File Size in Linux

    The Easy Ways to Check File Size in Linux

    Linux server security system administrators

    Best Practices Linux Server Security for System Administrator

    Backup Files From Remote Linux VPS Using Rsync Script

    How To Backup Files From Remote Linux VPS Using Rsync Script

    SSH Key-based Authentication

    How To Configure SSH Key-based Authentication In Linux

    Linux File Permissions

    Understanding Linux File Permissions for Beginners

    Create Multiboot USB with Ventoy

    How To Create Multiboot USB with Ventoy in Linux

    Find Hard Disk Drive Information in Linux

    How To Find Hard Disk Drive Information in Linux

No Result
View All Result
Linux Tutorials for Beginners
  • Ubuntu
    Install and Secure phpMyAdmin on Ubuntu 22.04

    How To Install and Secure phpMyAdmin on Ubuntu 22.04

    Secure SSH with Fail2Ban

    How To Secure SSH with Fail2Ban on Ubuntu 22.04

    Install Uptime Kuma on Ubuntu 22.04

    How To Install Uptime Kuma on Ubuntu 22.04

    Install Ubuntu Server 22.04

    How To Install Ubuntu Server 22.04 LTS with Screenshots

    Set Up Firewall on Ubuntu 22.04

    How To Set Up a Firewall with UFW on Ubuntu 22.04

    Install Nginx on Ubuntu

    How To Install Nginx on Ubuntu 22.04: A Comprehensive Guide

    Install MySQL 8.0 on Ubuntu 22.04

    How To Install MySQL 8.0 on Ubuntu Server 22.04

    install-php74-ubuntu2204

    How To Install PHP 7.4 on Ubuntu 22.04

    Install Snipe-IT on Ubuntu 22.04

    How To Install Snipe-IT Asset Management on Ubuntu 22.04

  • Debian
    Secure SSH with Fail2Ban

    How To Secure SSH with Fail2Ban on Debian 11

    Install Debian 11 Server

    How To Install Debian 11 (Bullseye) Server with Pictures

    Install and Setup Node.js on Debian 11

    How To Install and Setup Node.js on Debian 11

    Install PHP 8.2 on Debian 11

    How To Install PHP 8.2 on Debian 11

    Install Nginx on Debian 11

    How To Install Nginx on Debian 11: A Comprehensive Guide

    Set Up Firewall with UFW on Debian

    How To Set Up a Firewall with UFW on Debian 11

    install php74 on debian 11

    How To Install PHP 7.4 on Debian 11

    Install MariaDB 10.9 on Debian 11

    How To Install MariaDB 10.9 on Debian 11 Server

    Initial Setup Debian Server

    Initial Setup Debian 11 Server: Secure and Efficient

  • Rocky Linux
    Install phpMyAdmin on Rocky Linux 9

    How To Install phpMyAdmin on Rocky Linux 9

    Secure SSH with Fail2Ban

    How To Secure SSH with Fail2Ban on Rocky Linux 9

    Install Rocky Linux 9.2 Server

    How To Install Rocky Linux 9.2 Server with Screenshots

    setup Firewall Using Firewalld Rocky Linux 9

    How To Set Up a Firewall Using FirewallD on Rocky Linux 9

    Install Nginx on Rocky Linux 9

    How To Install Nginx on Rocky Linux 9: A Comprehensive Guide

    Install Apache on Rocky Linux

    How To Install and Configure Apache on Rocky Linux 9

    Install MongoDB on Rocky Linux 9

    How To Install MongoDB 6.0 on Rocky Linux 9

    Install Docker on Rocky Linux

    How To Install Docker CE on Rocky Linux 9

  • CentOS
    Secure SSH with Fail2Ban

    How To Secure SSH with Fail2Ban on CentOS 7

    Install PHP8.2 on CentOS 7

    How To Install PHP 8.2 on CentOS 7 / RHEL 7

    Install Apache on CentOS 7

    How To Install Apache Web Server on CentOS 7

    Set Up FirewallD on CentOS 7

    How To Set Up a Firewall Using FirewallD on CentOS 7

    Initial Setup CentOS 7 Server

    Initial Setup CentOS 7 Server: Secure and Efficient

    Install Nginx on CentOS 7

    How To Install Nginx on CentOS 7: A Comprehensive Guide

    Build NGINX from Source on Centos 7

    How To Build NGINX from Source (Compile) on Centos7

    Install Docker Swarm on CentOS 7

    Install and Configure Docker Swarm Mode on Centos 7

    Install Docker Compose on Centos 7

    How To Install and Use Docker Compose on Centos 7

  • Linux
    Manage Groups on Linux

    A Simple Guide: How To Manage Groups on Linux

    Logrotate In Linux

    How To Manage Log Files Using Logrotate In Linux

    Check File Size in Linux

    The Easy Ways to Check File Size in Linux

    Linux server security system administrators

    Best Practices Linux Server Security for System Administrator

    Backup Files From Remote Linux VPS Using Rsync Script

    How To Backup Files From Remote Linux VPS Using Rsync Script

    SSH Key-based Authentication

    How To Configure SSH Key-based Authentication In Linux

    Linux File Permissions

    Understanding Linux File Permissions for Beginners

    Create Multiboot USB with Ventoy

    How To Create Multiboot USB with Ventoy in Linux

    Find Hard Disk Drive Information in Linux

    How To Find Hard Disk Drive Information in Linux

No Result
View All Result
Linux Tutorials for Beginners
No Result
View All Result

Home » Ubuntu » How To Install Python 3.11 from Source on Ubuntu 22.04

How To Install Python 3.11 from Source on Ubuntu 22.04

sammbysamm
October 16, 2023
Install Python 3.11 on Ubuntu

How To Install Python 3.11 from Source on Ubuntu 22.04

Share on FacebookShare on LinkedinShare on Whatsapp

Introduction

Python, a versatile and powerful programming language, is constantly evolving with new versions offering enhanced features and performance improvements. Python 3.11 is one such version that brings exciting enhancements. To harness its full potential, how to install Python 3.11 from source on Ubuntu 22.04 can be a great choice. This comprehensive guide will walk you through the step-by-step process, ensuring a successful installation for optimal performance.

Table of Contents

  • Introduction
  • Why Install Python 3.11 from Source?
  • Python versions, Release Dates and EOL:
  • Prerequisites
  • Install Python 3.11 from Source
    • Step 1: System Update
    • Step 2: Install the Dependencies
    • Step 3: Download and Install python 3.11 from Source
  • Set up a Virtual Environment (Optional)
  • Create a Simple Python Program
  • Conclusion

Why Install Python 3.11 from Source?

Install Python 3.11 from source on Ubuntu provides several advantages over using the package manager. It allows you to have more control over the configuration, choose custom build options, and ensure compatibility with specific applications. Additionally, it lets you stay up-to-date with the latest Python release, utilizing its performance improvements and new features.

OTHER POSTS

How To Install and Secure phpMyAdmin on Ubuntu 22.04

How To Secure SSH with Fail2Ban on Ubuntu 22.04

How To Install Uptime Kuma on Ubuntu 22.04

Python versions, Release Dates and EOL:

VersionsReleased DatesEnd of life
3.1124 Oct 202224 Oct 2027
3.104 Oct 202104 Oct 2026
3.905 Oct 202005 Oct 2025
3.814 Oct 201914 Oct 2024
3.726 Jun 201827 Jun 2023
3.622 Dec 201623 Dec 2021
2.701 Oct 200829 Oct 2013
Python Released Dates and EOL

Prerequisites

Before getting started install Python 3.11 from source on Ubuntu, here is a list of requirements that you need:

  • Ubuntu Server: Make sure you have a clean installation of Ubuntu Server. To set this up, follow our guide : Initial Setup Ubuntu Server 22.04: Secure and Efficient. You can deploy this on a physical machine or a virtual environment like VMware or VirtualBox.
  • A stable internet connection to download packages
  • Familiarity with basic Linux commands

Install Python 3.11 from Source

If you want to install the latest Python version, you can use two options: installing from source or from a PPA.

Compiling Python on Ubuntu from source allows you to install the most recent Python version and customize the build parameters. However, you will be unable to maintain your Python installation using the apt package manager.

By default, Ubuntu 22.04 comes with Python version 3.10

samm@python3:~$ python3 -V
Python 3.10.12

Step 1: System Update

Before you begin, ensure that your system is up-to-date by running the following commands:

samm@python3:~$ sudo apt update
samm@python3:~$ sudo apt upgrade

Step 2: Install the Dependencies

Python is 3.11 is the most recent version of the most recent major release. This version incorporates several performance improvements and new features, such as new standards library modules, new syntax, and built-in capabilities, and more.

The following instructions outline the process of compiling Python 3.11 from source on Ubuntu. If you’re installing a newer release, simply modify the version number in the commands provided.

You’ll also need essential build tools and development libraries. Install them with:

samm@python3:~$ 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 3: Download and Install python 3.11 from Source

Now navigate to the Python’s download page and download the latest release of Python use wget to fetch it directly from the terminal:

samm@python3:~$ wget https://www.python.org/ftp/python/3.11.4/Python-3.11.4.tgz

Once the download is complete, extract the archive as follows:

samm@python3:~$ tar -xf Python-3.11.4.tgz

Open the Python on Ubuntu source directory and execute the configure command.

samm@python3:~$ cd Python-3.11.4/

Then execute the following ./configure command. The command runs a thorough test to check if all the dependencies for installing Python3 are met.

samm@python3:~/Python-3.11.4$ sudo ./configure --enable-optimizations

The --enable-optimizations option allows the Python binary to be optimized by running multiple tests. This slows down the building process.

Next, start the build process:

samm@python3:~/Python-3.11.4$ make -j 2

The -j$(nproc) flag parallelizes the build process, utilizing all available CPU cores. By entering nproc, you may find the number of cores in your system.

Once the build is finished, install the Python binaries by typing:

samm@python3:~/Python-3.11.4$ sudo make altinstall

We’re using altinstall instead of install since the later command would replace the system’s default python3 binary. Upon installation of all the required Python libraries, now confirm the version of Python installed.

samm@python3:~$ python3.11 -V

You should see the version information displayed.

Python 3.11.4

Python 3.11 releases with excellent promises. The best of all is its speed. It’s up to 60% faster than Python 3.10.

Set up a Virtual Environment (Optional)

By creating virtual environments, you can establish a separate space on your server for your Python projects. This enables each project to maintain a unique set of requirements without causing interference with any of the others. Now, let’s proceed to install Venv by entering:

samm@python3:~$ sudo apt install -y python3-venv

With that module installed, you can set up your environment in any directory of your preference. In this case, we will create a new directory and navigate into it.

samm@python3:~$ mkdir samm-environment && cd samm-environment

You can create an environment by executing the following command after you are in the directory where you want the environments to live:

samm@python3:~/samm-environment$ python3 -m venv my_env

You can view the contents of the virtual environment using the ls command as shown.

samm@python3:~/samm-environment$ ls my_env
output :
bin  include  lib  lib64  pyvenv.cfg

The python on Ubuntu 22.04 sharing directory will contain Python Wheels, a built-package format for Python that can speed up software development by reducing the number of compilations required.

You must activate this environment before using it, which you can do by entering the command that invokes the activate script as follows:

samm@python3:~/samm-environment$ source my_env/bin/activate

You’re environment’s name, in this case my_env, will now appear before your command prompt. Your prefix may alter somewhat depending on the Debian Linux version you are using, but the name of your environment in parentheses should be the first item you see on your line:

(my_env) samm@python3:~/samm-environment$

This prefix informs us that the environment my_env is now active, which means that any programs we write here will only make use of the parameters and components specific to this environment.

Note: You can choose to use the commands pip or python instead of pip3 inside the virtual environment. You must only use the python3 and pip3 commands if you use Python 3 on a system that is not part of an environment.

Your virtual environment is ready for usage once you’ve completed these procedures.

Create a Simple Python Program

The installation is completed now ready, so let’s make a classic “Hello, World!” program. This will allow us to test our environment and, if we haven’t already, provide us a chance to learn more about Python.

To accomplish this, we’ll create a simple Python file using the vim text editor. Here, our Python file is called ‘hello.py’.

(my_env) samm@python3:~/samm-environment$ vi hello.py
print("Hello, World!")

Save the file and exit.

Finally, we will run the program as follows.

(my_env) samm@python3:~/samm-environment$ python3 hello.py

The output from your terminal should look like this thanks to the hello.py program you wrote:

Output:
Hello, World!

Enter the command deactivate to exit the environment, and your current directory will be where you start.

(my_env) samm@python3:~/samm-environment$ deactivate
samm@python3:~/samm-environment$ 

Conclusion

By following this guide, you’ve successfully installed Python 3.11 from source on Ubuntu 22.04. This method provides you with greater control over your Python environment, allowing you to take full advantage of its enhanced features and improved performance. Whether you’re a developer or an enthusiast, exploring Python 3.11’s capabilities will undoubtedly enrich your programming journey.

Also Read Our Other Guides :

  • How To Install Python 3.11 on Rocky Linux 9
  • How To Install MySQL 8.0 on Ubuntu Server 22.04
  • How To Install MariaDB 10.9 on Debian 11 Server
  • How To Install MariaDB 10.6 on Debian 11 Server
  • How To Create AWS CloudFront: A Step-by-Step Guide

Hopefully, now you have learned how to install Python 3.11 from source on Ubuntu 22.04.

Tags: Programming LanguagePythonPython3Ubuntu

If you got help by our tutorials, please buy me a coffee..!

Buy Me a Coffee

Thank you so much for your support!!

Previous Post

How To Create AWS CloudFront: A Step-by-Step Guide

Next Post

How To Use Git Version Control on Linux: For Beginner

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

RECENT POST

Install and Secure phpMyAdmin on Ubuntu 22.04

How To Install and Secure phpMyAdmin on Ubuntu 22.04

by samm
July 22, 2024
0

Are you ready to take control of your MySQL databases on Ubuntu 22.04? In this step-by-step guide, we'll walk you...

Manage Groups on Linux

A Simple Guide: How To Manage Groups on Linux

by samm
November 12, 2023
0

Are you a Linux enthusiast looking to enhance your system administration skills? One fundamental aspect you should master is how...

Install phpMyAdmin on Rocky Linux 9

How To Install phpMyAdmin on Rocky Linux 9

by samm
November 11, 2023
0

If you're navigating the world of Rocky Linux 9 and looking to streamline your MariaDB or MySQL database management, installing...

Logrotate In Linux

How To Manage Log Files Using Logrotate In Linux

by samm
November 10, 2023
0

Log files are an essential part of any Linux system. They provide valuable insights into the system's activities, helping administrators...

Load More

RECOMMENDED.

Install Redis on Debian

How To Install Redis on Debian 11 Server

October 16, 2023
Secure SSH with Fail2Ban

How To Secure SSH with Fail2Ban on Rocky Linux 9

October 29, 2023
sammlinux sammlinux sammlinux

Related Posts

Install and Secure phpMyAdmin on Ubuntu 22.04
Ubuntu

How To Install and Secure phpMyAdmin on Ubuntu 22.04

July 22, 2024
Secure SSH with Fail2Ban
Ubuntu

How To Secure SSH with Fail2Ban on Ubuntu 22.04

October 29, 2023
Install Uptime Kuma on Ubuntu 22.04
Ubuntu

How To Install Uptime Kuma on Ubuntu 22.04

November 12, 2023
Install Ubuntu Server 22.04
Ubuntu

How To Install Ubuntu Server 22.04 LTS with Screenshots

October 21, 2023
Load More
Next Post
Use Git on Linux

How To Use Git Version Control on Linux: For Beginner

  • About Us
  • Disclaimers
  • Privacy Policy
  • Sitemap

© 2023 sammlinux - Learn Today for Lead Tomorrow.

No Result
View All Result
  • Ubuntu
  • Debian
  • Rocky Linux
  • CentOS
  • Linux

© 2023 sammlinux - Learn Today for Lead Tomorrow.