How to Install Python 3.11 on Fedora 36 Linux

Python is one of the most popular high-level languages, focusing on high-level and object-oriented applications from simple scrips to complex machine learning algorithms. Python is famous for its simple, easy-to-learn syntax, emphasizes readability, and reduces program maintenance costs and more straightforward conversion to newer releases. Python supports modules and packages, and one of the many is the popular PIP package manager.

Some of the features Python can do:

  • Python can be used on a server to create web applications.
  • Python can be used alongside software to create workflows.
  • Python can connect to database systems. It can also read and modify files.
  • Python can be used to handle big data and perform complex mathematics.
  • Python can be used for rapid prototyping or production-ready software development.

For users and especially developers wanting to try out Python’s latest release, you will know how to install Python 3.11 in the following tutorial on Fedora 36 workstation or server using the DNF package manager or by manually downloading and compiling Python along with creating a test environment.

Option 1. Install Python 3.11 with DNF

To install the latest versions of Python 3.11 is a relatively straightforward process, given Fedora 36 is based on new packages. This is already present and often updated regularly when new releases arrive.

To begin the installation, use the following command.

sudo dnf install python3.11 -y

Once installed, it is good to see what version build has been installed by using the following command.

python3.11 --version

Example output:

How to Install Python 3.11 on Fedora 36 Linux

Next, to open Python 3.11 shell, use the following command.

python3.11

Example terminal:

How to Install Python 3.11 on Fedora 36 Linux

To exit the Python 3.11 shell, use the following command.

exit()

All updates are handled using the standard DNF manager as you would typically do for your other Fedora 36 packages.

Option 2. Install Python 3.11 by Compiling Source

The alternative option for those that feel up to more of a challenge or require specific advanced builds from the git repository of the source can opt to install directly from the source. The main issue with this method is that you cannot quickly update like the APT package manager and will need to recompile for any changes.

First, you will need to install the dependencies necessary to build Python 3.11:

sudo dnf install gcc openssl-devel bzip2-devel libffi-devel zlib-devel wget make -y

The second part is visiting the source downloads page on Python’s website and getting the latest version using (wget):

wget https://www.python.org/ftp/python/3.11.0/Python-3.11{version number}

An example is taken URL from the Feb 3rd, 2022 release:

wget https://www.python.org/ftp/python/3.11.0/Python-3.11.0a6.tar.xz

Note, this is the Python 3.11 pre-release version at the time of the tutorial creation; visit and check for updates or use the Fedora DNF version if you are too lazy.

The file archive is small, so it won’t take long to download. Once done, extract the archive:

tar -xf Python-3.11*

Now move Python to the /opt/ directory location, I would recommend keeping the folder version name intact for future downloads, so you do not get confused.

sudo mv Python-3.11* /opt/

Switch to the source directory and run the configuration script, which does an essential run-through checklist to ensure all dependencies are present for the installation to work.

Example:

cd /opt/Python-3.11.0a6

Next, set the configuration script.

./configure --enable-optimizations

Note, the (–enabled-optimizations) is recommended as it optimizes the Python binary by running multiple tests but takes extra time to compete.

Overall the process should take a few minutes, so it’s recommended not to skip.

The next option is to use the (make) command to start the build process.

make -j 2

Note the (-j) corresponds to the number of cores in your system to speed up the build time. If you have a powerful server, you can set this as high as possible. If you don’t, it will be the default option of 1. To find out how many cores you have on your system, execute the following code:

nproc

Example output:

2

As you can see, we have two cores, so in the (make) command, we used (-j 2).

In the last step, once you have finished with the build process, you will install Python 3.11 source by executing the following:

sudo make altinstall

Note the guide has used (altinstall) instead of the default (install) because it will overwrite the default python3 binary python binary file /usr/bin/python.

Check the version of the installation to make sure it has been installed successfully and its current build number:

python3.11 --version

Example output:

Python 3.11.0a3+

To open Python 3.11 shell, use the following command.

python3.11

Example of terminal:

How to Install Python 3.11 on Fedora 36 Linux

To exit the Python 3.11 shell, use the following command.

exit()

Create a Test Virtual Environment

Python’s venv module is a virtual environment is a Python environment such that the Python interpreter, libraries, and scripts installed into it are isolated from those established in other virtual environments, and (by default) any libraries installed on your operating system, for example, those that are installed on your Linux Mint operating system to avoid clashing and disturbing your production environments.

To make sure Python 3.11 is installed correctly and functioning, create a quick Python project.

First, create the project directory and navigate to it:

mkdir ~/test_app && cd ~/test_app

Now inside the project root directory, run the following command to create a virtual environment, for the test name it test_app:

python3.11 -m venv test_app_venv

Next, activate the virtual environment as follows:

source test_app_venv/bin/activate

After starting the virtual environment, you will now be in the shell prompt terminal. You will notice the name of your environment will be prefixed. The tutorial example was (test_app_venv).

Example:

How to Install Python 3.11 on Fedora 36 Linux

By default, PIP3.11 should be installed. PIP is the most used package manager for Python.

Before you begin, check if any upgrades are available for PIP.

python3.11 -m pip install --upgrade pip

If you have trouble installing specific packages using PIP, you should install the following packages.

sudo dnf install gcc openssl-devel bzip2-devel libffi-devel zlib-devel wget make -y

The tutorial will now demonstrate installing Apache-Airflow with PIP and Python 3.11. This package needs additional packages to be installed, which are listed above.

Example:

pip3.11 install apache-airflow

Remove the test application using PIP3.11.

pip3.11 uninstall apache-airflow -y

To exit the virtual environment, use the following command:

deactivate

Comments and Conclusion

In the tutorial, you have learned how to install Python 3.11 on Fedora 36 by DNF or compile from source and learn how to create a quick virtual environment.

Overall, Python 3.11 is still in development at this point, so sticking with Python 3.9 to 3.10 may be more desirable for the time being. For those wanting to test the latest Python, 3.11 is worth the investment to install.



Follow LinuxCapable.com!

Like to get automatic updates? Follow us on one of our social media accounts!