Managing Multiple Python Versions on AlmaLinux with DNF Module Streams
Learn how AlmaLinux’s dnf module streams let you install and switch between different versions of the same software, such as Python 3.9 and 3.11, without package conflicts.
12 Aug 2025, 07:44 UTC

The problem: needing different versions of the same tool
When you maintain a server that runs several applications, you often encounter a situation where one service requires Python 3.9 while another needs Python 3.11. Installing both versions from the standard repositories would cause file conflicts, and building from source adds maintenance overhead. AlmaLinux provides a built‑in way to handle this through DNF module streams, which let you pick a specific version stream for a module and install its packages without interfering with other streams.
How DNF module streams work
A module in DNF groups related packages (for example, the python module) and exposes multiple streams, each representing a version line such as 3.9 or 3.11. Streams are separate repositories of metadata; enabling a stream tells DNF to resolve dependencies against that version’s package set. You can have only one stream of a given module enabled at a time, but you can switch streams as needed.
Worked example: switching between Python 3.9 and Python 3.11
The following commands illustrate the process. They have not been executed; you should run them in a test environment first and verify the output matches your expectations.
- List available streams for the
pythonmodule to see what versions are offered.
Expected output includes lines like# Run as root or with sudo sudo dnf module list pythonpython 3.9[d] ...andpython 3.11 ...where the[d]marks the default stream. - Enable the
3.9stream and install thepython3package.
After installation, check the version.sudo dnf module enable python:3.9 sudo dnf install python3
You should see something likepython3 --versionPython 3.9.x. - To switch to the newer stream, first disable the current one (or simply enable the other stream; DNF will automatically disable the conflicting stream).
Verify again.sudo dnf module reset python sudo dnf module enable python:3.11 sudo dnf install python3
The output should now showpython3 --versionPython 3.11.x.
Note: The exact version numbers depend on the repositories configured on your system. Always inspect the output of dnf module list before proceeding.
Trade‑offs and limitations
- Increased dependency complexity. When a stream is enabled, DNF resolves dependencies against that stream’s package set. If you later install a package that depends on a different stream of the same module, you may encounter unsatisfied dependencies unless you reset or switch streams first.
- Support lifecycle. Not all streams receive the same length of security updates. A stream that falls out of support will no longer receive patches, potentially leaving installed packages vulnerable. Check the AlmaLinux release notes or the module’s metadata for end‑of‑life dates.
- Not enabled by default. You must explicitly enable the stream you want; otherwise DNF will install the default stream, which may not be the version you need.
To mitigate these risks, keep a record of which streams are enabled on each host, test changes in a staging environment, and monitor AlmaLinux errata for stream deprecation notices.
Actionable closing
If you need to run multiple versions of a tool on AlmaLinux, start by exploring the available module streams with dnf module list <module-name>. Enable the stream that matches the version you require, install the package, and verify the version with the tool’s own version command (--version, -v, etc.). Document the enabled stream in your configuration management or runbook so future administrators know which version is intentional. When a stream approaches end‑of‑life, plan a migration to a newer stream well before support ends.
0 replies
A thoughtful contribution can make all the difference. Be the first to share one.