All Products
Search
Document Center

Alibaba Cloud Linux:How to install and use a higher version of Python 3 on Alibaba Cloud Linux 3

Last Updated:Feb 03, 2026

This topic describes how to install and configure a higher version of Python 3 on Alibaba Cloud Linux 3.

Alibaba Cloud Linux 3 (Alinux3) ships with Python 3.6 by default. Core system components, such as dnf, depend on this version. To ensure system stability and compatibility, the default python3 command will not be upgraded.

To meet developer needs for newer Python versions, the official YUM repository for Alinux3 provides multiple higher Python versions. You can safely install and run these versions alongside the system default without affecting system stability.

Depending on your Alinux3 image version, the supported higher Python versions are as follows:

System version

Supported higher Python versions

Alibaba Cloud Linux 3.2104

Python 3.8, Python 3.11

Alibaba Cloud Linux 3.2104 AI Extension Edition

Python 3.8, Python 3.10, Python 3.11, Python 3.12

Install a higher version of Python 3

  1. Install Python 3.8.

yum install python38 -y
  1. Install Python 3.11.

yum install python3.11 -y
  1. Install Python 3.10.

yum install python3.10 -y
  1. Install Python 3.12.

yum install python3.12 -y

Use a higher version of Python 3

The system-default Python 3 is used by multiple core components, such as dnf and firewalld. Directly upgrading or replacing the default Python version can cause system instability, tool failures, or service failures. This practice is strongly discouraged.

The following method describes how to safely use a higher Python version, such as Python 3.11. This approach meets development needs while preserving system integrity.

A Python virtual environment (venv) creates an isolated runtime for each project. It isolates dependencies, prevents package version conflicts, and avoids impacting the system-level Python environment. This is the recommended development and deployment mode in the Python 3 ecosystem.

The following steps use Python 3.11 as an example:

  1. Explicitly invoke the higher Python version.

After you install Python 3.11, you can call it using its version-suffixed command:

python3.11 --version
pip3.11 --version
  1. Create a virtual environment.

You can create an isolated virtual environment using Python 3.11. You can also customize the path:

python3.11 -m venv ~/venv/python311
  1. Activate the virtual environment.

source ~/venv/python311/bin/activate

After activation, your command prompt usually shows the environment name, such as (python311).

  1. Verify the current environment.

After the virtual environment is activated, the python and pip commands automatically point to Python 3.11:

python --version      # Output: Python 3.11.x
pip --version         # Uses pip for Python 3.11
  1. Exit the virtual environment.

Run the following command to exit the virtual environment:

deactivate

After you exit, the python and pip commands revert to the system-default Python version.

Frequently asked questions

  1. Can I use the alternatives command to configure the python command to point to a higher version of Python?

No, you should not.

If /usr/bin/python exists and points to the default Python 3.6, changing its target will affect all scripts and tools that rely on this path.

If a component or service explicitly calls /usr/bin/python during startup or runtime, pointing it to an incompatible Python version can cause critical issues, such as a service startup failure.

  1. Can I directly replace /usr/bin/python3 or add a new /usr/local/bin/python3 symbolic link pointing to a higher Python version?

No, you should not.

Modifying /usr/bin/python3 or creating a symbolic link at /usr/local/bin/python3 that points to a higher Python version is a system-wide global change that can have a broad impact.

  • /usr/bin/python3 is the system-default command path and is directly referenced by many scripts, tools, and services.

  • /usr/local/bin is also in the PATH search path for most users and typically has a higher priority than /usr/bin. Adding a command with the same name in this location can lead to unintended invocations.

Pointing these paths to a higher Python 3 version can cause the following issues:

  • Incompatibility in the Application Binary Interface (ABI) or standard library behavior between Python versions.

  • System tools crashing due to import failures or syntax incompatibilities.

  • Third-party RPM package installation scripts failing unexpectedly.

  • The entire system becoming unmaintainable.