Skip to main content
Redhat Developers  Logo
  • AI

    Get started with AI

    • Red Hat AI
      Accelerate the development and deployment of enterprise AI solutions.
    • AI learning hub
      Explore learning materials and tools, organized by task.
    • AI interactive demos
      Click through scenarios with Red Hat AI, including training LLMs and more.
    • AI/ML learning paths
      Expand your OpenShift AI knowledge using these learning resources.
    • AI quickstarts
      Focused AI use cases designed for fast deployment on Red Hat AI platforms.
    • No-cost AI training
      Foundational Red Hat AI training.

    Featured resources

    • OpenShift AI learning
    • Open source AI for developers
    • AI product application development
    • Open source-powered AI/ML for hybrid cloud
    • AI and Node.js cheat sheet

    Red Hat AI Factory with NVIDIA

    • Red Hat AI Factory with NVIDIA is a co-engineered, enterprise-grade AI solution for building, deploying, and managing AI at scale across hybrid cloud environments.
    • Explore the solution
  • Learn

    Self-guided

    • Documentation
      Find answers, get step-by-step guidance, and learn how to use Red Hat products.
    • Learning paths
      Explore curated walkthroughs for common development tasks.
    • Guided learning
      Receive custom learning paths powered by our AI assistant.
    • See all learning

    Hands-on

    • Developer Sandbox
      Spin up Red Hat's products and technologies without setup or configuration.
    • Interactive labs
      Learn by doing in these hands-on, browser-based experiences.
    • Interactive demos
      Click through product features in these guided tours.

    Browse by topic

    • AI/ML
    • Automation
    • Java
    • Kubernetes
    • Linux
    • See all topics

    Training & certifications

    • Courses and exams
    • Certifications
    • Skills assessments
    • Red Hat Academy
    • Learning subscription
    • Explore training
  • Build

    Get started

    • Red Hat build of Podman Desktop
      A downloadable, local development hub to experiment with our products and builds.
    • Developer Sandbox
      Spin up Red Hat's products and technologies without setup or configuration.

    Download products

    • Access product downloads to start building and testing right away.
    • Red Hat Enterprise Linux
    • Red Hat AI
    • Red Hat OpenShift
    • Red Hat Ansible Automation Platform
    • See all products

    Featured

    • Red Hat build of OpenJDK
    • Red Hat JBoss Enterprise Application Platform
    • Red Hat OpenShift Dev Spaces
    • Red Hat Developer Toolset

    References

    • E-books
    • Documentation
    • Cheat sheets
    • Architecture center
  • Community

    Get involved

    • Events
    • Live AI events
    • Red Hat Summit
    • Red Hat Accelerators
    • Community discussions

    Follow along

    • Articles & blogs
    • Developer newsletter
    • Videos
    • Github

    Get help

    • Customer service
    • Customer support
    • Regional contacts
    • Find a partner

    Join the Red Hat Developer program

    • Download Red Hat products and project builds, access support documentation, learning content, and more.
    • Explore the benefits

How to change the meaning of python and python3 on RHEL

September 30, 2025
Tomáš Hrnčiar
Related topics:
LinuxProgramming languages & frameworksPython
Related products:
Red Hat Enterprise Linux

    Historically, administrators of Red Hat Enterprise Linux (RHEL) used the alternatives command to change the system's default python3 interpreter. This method was technically a challenge to support. Because the system Python is deeply integrated into RHEL, changing its version can break critical components. This post explains why alternatives is unsupported in RHEL 9 and later, and offers a safer alternative.

    Python is a vital system component

    Numerous core RHEL components are tightly coupled with the system's version of Python. One prominent example is dnf, the package manager that installs and updates applications. It's a Python application and relies on the Python version it was tested with. An unauthorized change to the system's default Python environment could render a tool like dnf inoperable, effectively crippling your ability to manage software on the system, which could lead to a broken operating system. Other critical tools, from firewall managers to system initializers and printer drivers, also often depend on the default system Python and could fail unexpectedly should the Python version unexpectedly change.

    Even though RHEL 9 was released in 2022, some users still ask how to change what gets executed when the python3 command is issued. For example, a user might want to configure a system to run /usr/bin/python3.11 rather than, for instance, /usr/bin/python3.9 when python3 is called.

    The best solution is to keep the system Python untouched, and instead create a symbolic link that redefines python3 on your system to your desired Python interpreter. This has zero impact on system packages or other users. It's also easy to reverse by simply removing the symbolic link file.

    As root you can do:

    # sudo ln -s /usr/bin/python3.11 /usr/local/bin/python3
    # python3 --version
    Python 3.11.11
    # ls -la /usr/local/bin/python*
    lrwxrwxrwx. 1 root root 19 Jun 23 09:06 /usr/local/bin/python3 -> /usr/bin/python3.11
    # echo $PATH
    /root/.local/bin:/root/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin

    When the symbolic link is created by root, it is also available for other users and services on the system.

    As a regular user:

    $ ln -s /usr/bin/python3.11 ~/.local/bin/python3
    $ python3 --version
    Python 3.11.11
    $ ls -laG ~/.local/bin/python3
    lrwxrwxrwx. 1 tux 19 Jun 24 05:41 /home/tux/.local/bin/python3 -> /usr/bin/python3.11
    $ echo $PATH
    /home/tux/.local/bin:/home/tux/bin:/usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin

    You can safely do the same with the python command.

    Both /usr/local/bin/ and ~/.local/bin/ are part of the default PATH environment variable, so the python3 command will always use a symbolic link defined there.

    Use env in scripts for portability

    In your scripts, you can use #!/usr/bin/env python3 instead of hard-coding the path #!/usr/bin/python3. This ensures improved script portability.

    Different systems (or even different users on the same system) might have the same program installed in different locations. For example:

    • On a standard Linux system, Python might be in /usr/bin/python3
    • A user might have a new version installed in a different location.
    • A developer might use a virtual environment (venv), which puts a python3 executable in a project-specific bin directory and prepends that to the PATH.

    A script with a hard-coded path like #!/usr/bin/python3 uses the system Python in all but the first case.

    A script starting with #!/usr/bin/env python3 handles all these scenarios. It also respects the user's configured environment. When a developer has intentionally placed a specific version of Python first in their PATH, env finds it and uses that version. This allows users to control which interpreter runs a script without modifying the script itself.

    The art of managing interpreters

    Your Linux system can help you manage the version of Python and other popular programming languages and interpreters. Should you wish to override the default settings, there are tools built into Linux to let you do that in a safe and portable way. Use env in your scripts, venv while developing Python applications, maintain your PATH, and use symlinks for targeted overrides.

    Related Posts

    • How to install multiple versions of Python on Red Hat Enterprise Linux

    • Making memcpy(NULL, NULL, 0) well-defined

    • How to deploy a Flask application in Python with Gunicorn

    • A beginner's guide to Python containers

    • How to use a Python multiprocessing module

    • How to manage Python dependencies in Ansible execution environments

    Recent Posts

    • Trusted software factory: Building trust in the agentic AI era

    • Build a zero trust AI pipeline with OpenShift and RHEL CVMs

    • Red Hat Hardened Images: Top 5 benefits for software developers

    • How EvalHub manages two-layer Kubernetes control planes

    • Tekton joins the CNCF as an incubating project

    What’s up next?

    Whether you're deploying to the cloud, managing systems, or working with containers, the Red Hat Enterprise Linux 10 cheat sheet provides the key information you need for executing essential commands, image building, and system management.

    Get the cheat sheet
    Red Hat Developers logo LinkedIn YouTube Twitter Facebook

    Platforms

    • Red Hat AI
    • Red Hat Enterprise Linux
    • Red Hat OpenShift
    • Red Hat Ansible Automation Platform
    • See all products

    Build

    • Developer Sandbox
    • Developer tools
    • Interactive tutorials
    • API catalog

    Quicklinks

    • Learning resources
    • E-books
    • Cheat sheets
    • Blog
    • Events
    • Newsletter

    Communicate

    • About us
    • Contact sales
    • Find a partner
    • Report a website issue
    • Site status dashboard
    • Report a security problem

    RED HAT DEVELOPER

    Build here. Go anywhere.

    We serve the builders. The problem solvers who create careers with code.

    Join us if you’re a developer, software engineer, web designer, front-end designer, UX designer, computer scientist, architect, tester, product manager, project manager or team lead.

    Sign me up

    Red Hat legal and privacy links

    • About Red Hat
    • Jobs
    • Events
    • Locations
    • Contact Red Hat
    • Red Hat Blog
    • Inclusion at Red Hat
    • Cool Stuff Store
    • Red Hat Summit
    © 2026 Red Hat

    Red Hat legal and privacy links

    • Privacy statement
    • Terms of use
    • All policies and guidelines
    • Digital accessibility

    Chat Support

    Please log in with your Red Hat account to access chat support.