How to Install Python on Fedora 39/38/37 Linux

Python is a high-level, interpreted programming language that has gained immense popularity over the years due to its simplicity, readability, and versatility. Created by Guido van Rossum in 1989 and first released in 1991, Python has evolved into a powerful language widely used for various applications, from web development and data analysis to artificial intelligence and machine learning. In this introduction, we will explore the key aspects of Python programming that make it stand out among other languages.

Key Features and Benefits of Python Programming:

  • Readability: Python’s syntax is designed to be clean and easily readable, making it an excellent choice for both beginner and experienced programmers. The use of indentation to define code blocks and a focus on simplicity contribute to the language’s readability and maintainability.
  • Versatility: Python is a general-purpose programming language, which means it can be used for a wide range of applications. Its extensive standard library and numerous third-party packages make it suitable for web development, scientific computing, data analysis, automation, and much more.
  • Cross-platform Compatibility: Python runs on various platforms, including Windows, macOS, and Linux. This cross-platform compatibility makes it a valuable tool for developing applications that need to work seamlessly across different operating systems.
  • Strong Community Support: Python has a vast and active community of users, contributors, and developers who continuously work to improve the language and its ecosystem. This strong community support means that you’ll find a wealth of resources, tutorials, and libraries to help you with your Python projects.
  • Language Interoperability: Python can easily integrate with other programming languages, such as C, C++, and Java, allowing developers to utilize the best features of multiple languages in their projects.
  • Wide Adoption in Industry: Python’s flexibility and ease of use have made it a popular choice for many industries, including finance, healthcare, and technology. Its widespread adoption means that learning Python can open doors to a variety of career opportunities.

Whether you are just starting your programming journey or are an experienced developer looking to add a new language to your skillset, Python is a fantastic choice. With its intuitive syntax, extensive capabilities, and supportive community, Python offers a rewarding and engaging programming experience. The following guide will demonstrate how to install Python on Fedora Linux using Fedora’s repository.

Update Fedora

It is important to update your system regularly to ensure that your Fedora operating system is equipped with the latest versions of all packages. This can be achieved through a simple command entered in the terminal:

sudo dnf upgrade --refresh

Method 1: Install Python with Fedora

Installing Python on Fedora is straightforward, given its focus on upstream releases. To install Python run the following command:

sudo dnf install python

Python is a universal programming language, and many optional packages can be installed to take advantage of its full range of capabilities. Below is a list of some of the most popular optional Python packages that can be installed on Fedora Linux using the following command format:

Pip: a package installer for Python

sudo dnf install python3-pip

Python3-devel: development headers and libraries for Python 3

sudo dnf install python3-devel

Python3-venv: a tool for creating virtual environments for Python 3

sudo dnf install python3-vituralenv

NumPy: a library for working with arrays of numerical data

sudo dnf install python-numpy

SciPy: a library for scientific computing and advanced mathematics

sudo dnf install python-scipy

Matplotlib: a library for data visualization

sudo dnf install python-matplotlib

Pandas: a library for data analysis and manipulation

sudo dnf install python-pandas

Scikit-learn: a library for machine learning and data mining

sudo dnf install python-scikit-learn

Flask: a web application framework for Python

sudo dnf install python-flask

Django: a high-level web framework for Python

sudo dnf install python-django

Requests: a library for making HTTP requests

sudo dnf install python-requests

By installing these optional packages, you can expand the capabilities of your Python environment and enable a wide range of functionality. Whether you are working on data analysis, web development, or machine learning projects, installing these packages can help you achieve your goals more efficiently and effectively.

Verify the installation by checking the build.

python3 --version

Method 2: Install Python with Source

If you’re looking for a more advanced installation method for Python or need to install a specific advanced build from the Git repository of the source, you can choose to install Python directly from the source. However, it’s worth noting that this method can be more challenging and time-consuming than installing Python through a package manager. One of the main issues is that you won’t be able to update Python as easily as with a package manager, and you’ll need to recompile for any changes.

To install Python from the source on Fedora Linux, you’ll need to follow a few steps. First, you’ll need to install the necessary dependencies to build Python, including gcc, openssl-devel, bzip2-devel, libffi-devel, zlib-devel, wget, and make. You can do this by running the following command in the terminal:

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

Once you have installed the dependencies, you can visit the Python downloads page on the official website and download the latest version of Python. For example, you can use the wget command to download the Python 3.11.2 source file by running the following command:


Once you have downloaded the file, you can extract the archive by running the following command:

tar -xf Python-3.11.2.tar.xz

You’ll then need to navigate to the source directory by running the following command:

cd Python-3.11.2

Next, you’ll need to run the configuration script, which checks that all the necessary dependencies are present before the installation can proceed. You can run the configuration script with the following command:

./configure --enable-optimizations

It’s recommended to use the –enable-optimizations flag to optimize the Python binary by running multiple tests, although it will take extra time to complete.

After running the configuration script, you can start the build process with the make command. You can use the -j flag to specify the number of cores in your system to speed up the build time. For example, if you have two cores, you can run the following command:

make -j 2

Once the build process is complete, you can install Python by running the following command:

sudo make altinstall

The altinstall command is used instead of the default install command to prevent overwriting the default python3 binary file /usr/bin/python.

Finally, you can check the version of the installation to ensure that it has been installed successfully and that its current build number is correct by running the following command:

python3 --version

Test Python: Create a Test Virtual Environment

After installing Python on your Fedora Linux system, it’s a good idea to test that it’s working correctly. A convenient way to do this is by creating a test virtual environment. A virtual environment is an isolated environment where you can test Python and its modules without affecting the global Python environment.

To create a test virtual environment, you’ll first need to install the python3-virtualenv package, including the venv module you can use to create virtual environments. You can install it by running the following command:

sudo dnf install python3-virtualenv

Once you have installed the package, you can create a new virtual environment in a directory of your choice. For example, you can create a virtual environment called myenv by running the following command:

python3 -m venv myenv

This will create a new directory called myenv that contains the virtual environment. You can activate the virtual environment by running the activate script located in the bin directory of the virtual environment. You can activate the virtual environment by running the following command:

source myenv/bin/activate

Once you have activated the virtual environment, you can test Python by running the following command:

python --version

This will display the version of Python that you’re running in the virtual environment. You can also install any Python modules that you want to test in the virtual environment using pip. For example, you can install the NumPy package by running the following command:

pip install numpy

This will install the NumPy package in the virtual environment. You can test that the package is installed correctly by importing it into a Python script and running it. For example, you can create a new file called with the following code:

import numpy as np
arr = np.array([1, 2, 3])

Save the file and run it by running the following command:


This should output the following result:

[1 2 3]

By creating a test virtual environment and testing Python and its modules in isolation, you can ensure that everything is working correctly and avoid potential issues with the global Python environment. Once you’re done testing, you can deactivate the virtual environment by running the following command:


This will return you to the global Python environment.

Conclusion: Installing Python on Fedora Linux

In conclusion, Python is a versatile programming language that has become increasingly popular recently. It’s widely used in various applications, from web development to scientific computing and machine learning. If you’re using Fedora Linux, you have several options for installing Python, including using the default version from the Fedora repository, installing optional packages and essential components, or installing directly from the source. This should be enough to get you started with Python.

Share to...