Guides 11792 Published by

This guide walks readers through replacing the stock Python version on Rocky 8, Alma Linux 8, or Fedora 35 with a fresh build of Python 3.10 by compiling from source, detailing prerequisites such as development tools and SSL headers before downloading the official tarball. It explains why older distribution‑supplied interpreters can cause import errors due to mismatched feature sets and shows how to verify the current version with a simple command. After configuring with optimizations, the tutorial runs make and altinstall, installs binaries into /opt/python310, creates a symlink for easy access, and optionally lets users switch the system python3 using update‑alternatives. For Fedora 35 users it offers a quick module install alternative that pulls Python 3.10 from the repo, while reminding readers to be cautious about affecting system tools when overriding default binaries.



Get Python 3.10 on Rocky 8, Alma Linux 8, or Fedora 35 in a few minutes

You’ll learn how to drop the default 3.7/3.9 that ships with these distributions and install a clean, up‑to‑date 3.10 without messing with your system’s package manager.

Why the stock Python isn’t enough

I’ve seen developers stare at an “ImportError: cannot import name ‘asyncio’” after pulling in a new library on Rocky 8. The culprit? A mismatched runtime version that the distro ships with is older than what the code expects. If you want to use the newest language features or keep pace with the ecosystem, installing 3.10 yourself is worth it.

Step 1: Check what you already have
python3 --version

If it shows something like Python 3.7.x (Rocky/Alma) or Python 3.9.x (Fedora), you’re ready to replace it. If you have a newer version, skip ahead to Set the default.

Step 2: Install build dependencies
sudo dnf groupinstall "Development Tools" -y
sudo dnf install openssl-devel bzip2-devel libffi-devel zlib-devel \
                 wget make gcc -y

These packages give you a compiler, the necessary headers for SSL and bz2 support, and wget to fetch the source.

Step 3: Pull the Python 3.10 source
mkdir -p ~/src
cd ~/src
wget https://www.python.org/ftp/python/3.10.12/Python-3.10.12.tgz
tar xzf Python-3.10.12.tgz

(If you’re on Rocky/Alma, you can also use the distro tool to figure out your exact OS version and confirm that these URLs are still valid.)

Step 4: Configure for a clean install
cd Python-3.10.12
./configure --enable-optimizations \
            --with-ensurepip=install \
            --prefix=/opt/python310

Why --enable‑optimizations?

It runs pyexpat, math, and a few other modules through the compiler’s -O3 flag, giving you a slightly faster interpreter—worth a couple of extra minutes during build.

Step 5: Build & install
make -j$(nproc)
sudo make altinstall

Why altinstall?

It installs the binaries as python3.10 and pip3.10, leaving the system’s default /usr/bin/python3 untouched so that your OS tools stay happy.

Step 6: Wire it into your environment
sudo ln -s /opt/python310/bin/python3.10 /usr/local/bin/python310

Add to your shell profile if you want python310 to be found automatically:

echo 'export PATH=/usr/local/bin:$PATH' >> ~/.profile
source ~/.profile

Now check it:

python310 --version   # should say Python 3.10.12
pip310 --version      # should match the same major/minor
Step 7: (Optional) Make python3 point to 3.10

If you’re comfortable overriding the default, use update-alternatives.

This keeps a single command (python3) pointing at your new version:

sudo alternatives --install /usr/bin/python3 python3 /opt/python310/bin/python3.10 1
sudo alternatives --config python3   # pick the 3.10 entry

Be careful: some distro scripts still rely on the older interpreter. I’d leave python (the legacy 2.x) and python3 as is unless you know what you’re doing.

Step 8: Verify with a quick feature test
python310 - <<'EOF'
import sys, ssl
print(sys.version)
print(ssl.OPENSSL_VERSION)
EOF

You should see the Python version and your system’s OpenSSL library. If that prints fine, you’re good to go.

Fedora 35: A shortcut with modules

Fedora 35 ships a newer dnf that supports “modules.” You can try:

sudo dnf module install python3:10 -y

If the stream is available, this pulls in 3.10 from the repo and does all the heavy lifting for you—no compilation needed. On older Fedora releases or if the module isn’t present, fall back to the source method above.

Bottom line

Compiling from source gives you a fresh 3.10 that stays out of the way of the OS’s own Python. It also lets you install the exact patch level you need without waiting for a repo build. If you want a quick “just work” solution, Fedora’s module system is a handy shortcut; otherwise, the steps above will get you up and running on Rocky or Alma with minimal fuss.

Happy coding, and may your scripts run faster than the coffee machine!