Python 3.13 brings significant performance improvements, a new interactive interpreter, and better error messages. This guide covers two methods to install Python 3.13 on RHEL 10, Rocky Linux 10, and AlmaLinux 10 – from the default repositories and by building from source.

All commands in this guide have been tested on RHEL 10, Rocky Linux 10, and AlmaLinux 10. They should work identically across all three distributions since they share the same package base.

Prerequisites

Before you begin, make sure you have:

  • A running RHEL 10, Rocky Linux 10, or AlmaLinux 10 system
  • A user account with sudo privileges (or root access)
  • An active internet connection
  • At least 1 GB of free disk space (for building from source)

Update your system packages first:

sudo dnf update -y

Method 1: Install Python 3.13 from Default Repositories

RHEL 10 and its derivatives ship Python 3.13 in the AppStream repository. This is the fastest and simplest way to get Python 3.13 running.

Step 1: Check Available Python Versions

List the Python packages available in your repositories:

dnf list available python3*

Step 2: Install Python 3.13

Install the Python 3.13 package along with pip:

sudo dnf install -y python3 python3-pip python3-devel

Step 3: Verify the Installation

python3 --version

Expected output:

Python 3.13.x

Also verify pip:

pip3 --version

You should see pip pointing to Python 3.13. If the repo method gives you what you need, you can skip to the “Set Up pip” section below. If you need the absolute latest Python 3.13.x release, continue with Method 2.

Method 2: Build Python 3.13 from Source

Building from source gives you full control over the Python version and compile-time options. This is useful when you need a specific patch release or want to enable optimizations.

Step 1: Install Development Dependencies

Install the compiler toolchain and libraries required to build Python with full module support:

sudo dnf groupinstall -y "Development Tools"

sudo dnf install -y \
  gcc \
  gcc-c++ \
  make \
  openssl-devel \
  bzip2-devel \
  libffi-devel \
  zlib-devel \
  readline-devel \
  sqlite-devel \
  xz-devel \
  tk-devel \
  gdbm-devel \
  libuuid-devel \
  ncurses-devel \
  wget

Verify that gcc is installed:

gcc --version

Step 2: Download the Python 3.13 Source

Download the latest Python 3.13 release from the official site:

export PYTHON_VERSION=3.13.2
cd /tmp
wget https://www.python.org/ftp/python/${PYTHON_VERSION}/Python-${PYTHON_VERSION}.tgz

Extract the archive:

tar -xzf Python-${PYTHON_VERSION}.tgz
cd Python-${PYTHON_VERSION}

Step 3: Configure the Build

Run the configure script with optimization flags. The --enable-optimizations flag runs profile-guided optimization (PGO), which makes Python about 10-20% faster at the cost of a longer build time. The --with-ensurepip flag includes pip in the installation.

./configure \
  --prefix=/usr/local \
  --enable-optimizations \
  --enable-shared \
  --with-ensurepip=install \
  --with-system-ffi \
  LDFLAGS="-Wl,-rpath /usr/local/lib"

The LDFLAGS line ensures the system can find the shared Python library at runtime without needing to modify ld.so.conf separately.

Verify the configure step completed without errors. Look at the output summary – it should show all expected modules will be built. Pay attention to any modules listed under “The following modules were NOT found”.

Step 4: Compile Python

Build Python using all available CPU cores:

make -j $(nproc)

This will take several minutes depending on your hardware, especially with PGO enabled.

Step 5: Install Python

Use altinstall instead of install to avoid overwriting the system Python binary:

sudo make altinstall

Important: Always use make altinstall when building from source. Using make install will overwrite the default python3 binary, which can break system tools that depend on the distribution-provided Python.

Step 6: Update the Shared Library Cache

sudo ldconfig

Step 7: Verify the Source Installation

python3.13 --version

Expected output:

Python 3.13.2

Check pip as well:

pip3.13 --version

Confirm the installation path:

which python3.13

This should return /usr/local/bin/python3.13.

Set Up pip

If you installed from the repos, pip should already be available. If you built from source, pip was installed as pip3.13. Upgrade pip to the latest version:

# For repo install:
python3 -m pip install --upgrade pip

# For source install:
python3.13 -m pip install --upgrade pip

Configure pip.conf for a Custom Package Index

If your organization uses a private PyPI mirror or artifact repository (such as Nexus, Artifactory, or devpi), configure pip to point to it:

mkdir -p ~/.config/pip

cat > ~/.config/pip/pip.conf <<'EOF'
[global]
index-url = https://your-private-pypi.example.com/simple/
trusted-host = your-private-pypi.example.com
timeout = 60

[install]
trusted-host = your-private-pypi.example.com
EOF

For system-wide configuration, place the file at /etc/pip.conf instead.

Verify your pip configuration:

pip3 config list

Create Virtual Environments with venv

Always use virtual environments for your Python projects. This keeps project dependencies isolated and avoids polluting the system Python installation.

Create a Virtual Environment

# For repo install:
python3 -m venv ~/myproject-env

# For source install:
python3.13 -m venv ~/myproject-env

Activate the Virtual Environment

source ~/myproject-env/bin/activate

Your prompt will change to show the active environment name. Verify you are in the virtual environment:

which python
python --version
pip --version

All three commands should point to paths inside ~/myproject-env/.

Install Common Packages in the Virtual Environment

With the virtual environment activated, install packages as needed:

pip install requests flask django numpy pandas

List installed packages:

pip list

Export a requirements file for reproducibility:

pip freeze > requirements.txt

Deactivate the Virtual Environment

deactivate

Managing Multiple Python Versions

If you have multiple Python versions installed (for example, the system Python and a source-built Python 3.13), you can manage them with the alternatives system.

Configure alternatives

Register your Python installations with the alternatives system:

# Register the system Python (adjust version as needed)
sudo alternatives --install /usr/bin/python3 python3 /usr/bin/python3.13 1

# Register the source-built Python
sudo alternatives --install /usr/bin/python3 python3 /usr/local/bin/python3.13 2

The number at the end is the priority – higher numbers have higher priority.

Switch Between Python Versions

sudo alternatives --config python3

This will display a list of registered Python versions. Enter the selection number for the version you want to use as the default.

Verify the active version:

python3 --version
which python3

Alternative: Use Version-Specific Commands Directly

Instead of modifying system defaults, you can call specific versions directly. This is often the safer approach:

# Use system Python
/usr/bin/python3 --version

# Use source-built Python
/usr/local/bin/python3.13 --version

# Create venvs with specific versions
/usr/local/bin/python3.13 -m venv ~/myproject-env

Troubleshooting

Missing Shared Libraries

If you see an error like this when running python3.13:

python3.13: error while loading shared libraries: libpython3.13.so.1.0: cannot open shared object file: No such file or directory

The shared library is not in the linker search path. Fix it:

echo "/usr/local/lib" | sudo tee /etc/ld.so.conf.d/python3.13.conf
sudo ldconfig

Verify the library is found:

ldd /usr/local/bin/python3.13 | grep libpython

You should see libpython3.13.so.1.0 => /usr/local/lib/libpython3.13.so.1.0.

SSL Module Errors

If Python reports ModuleNotFoundError: No module named '_ssl' or pip fails with SSL errors, the OpenSSL development headers were missing during compilation.

Fix it by installing the headers and rebuilding:

sudo dnf install -y openssl-devel

Then re-run the configure, make, and make altinstall steps from Method 2. After rebuilding, verify the SSL module loads:

python3.13 -c "import ssl; print(ssl.OPENSSL_VERSION)"

If RHEL 10 ships OpenSSL 3.x and you encounter compatibility issues, make sure you are using Python 3.13.1 or later, which has full OpenSSL 3.x support.

pip Certificate Verification Errors

If pip fails with certificate errors like SSLCertVerificationError or CERTIFICATE_VERIFY_FAILED:

1. Check your system CA certificates are up to date:

sudo dnf install -y ca-certificates
sudo update-ca-trust

2. If you are behind a corporate proxy with SSL inspection, export the proxy’s CA certificate and add it to the system trust store:

sudo cp corporate-ca.crt /etc/pki/ca-trust/source/anchors/
sudo update-ca-trust

3. As a temporary workaround (not recommended for production), you can tell pip to skip certificate verification:

pip install --trusted-host pypi.org --trusted-host files.pythonhosted.org package-name

4. Verify pip can reach PyPI over HTTPS:

python3.13 -c "import urllib.request; urllib.request.urlopen('https://pypi.org')" && echo "SSL OK"

Build Fails with “ModuleNotFoundError: No module named ‘_ctypes'”

This means libffi-devel was not installed before building. Install it and rebuild:

sudo dnf install -y libffi-devel

Then re-run configure, make, and make altinstall.

tkinter Not Available

If you need tkinter for GUI applications:

sudo dnf install -y tk-devel

Rebuild Python from source, then verify:

python3.13 -c "import tkinter; print('tkinter OK')"

Summary

You now have Python 3.13 running on RHEL 10, Rocky Linux 10, or AlmaLinux 10. For most use cases, installing from the default repositories (Method 1) is the right choice – it gets security updates through your normal system update process. Building from source (Method 2) makes sense when you need the latest patch release or specific compile options.

Key points to remember:

  • Always use make altinstall when building from source to avoid breaking system Python
  • Use virtual environments for all project work
  • Use the alternatives system or direct paths to manage multiple Python versions
  • Install all development headers before building to avoid missing module errors

2 COMMENTS

  1. This procedure worked like a charm (I need to get off Python 3.6.8 ASAP but will be trapped on CentOS-7.9 for at least another year).

LEAVE A REPLY

Please enter your comment!
Please enter your name here