> ## Documentation Index
> Fetch the complete documentation index at: https://kb.hosting.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Configuring and using a newer version of Python

> Discover how to download and compile the latest Python version from source in this guide.

This article describes how to configure and use a newer Python version. You may want to do this if:

* You have an account on a managed server, and you want to use a version of Python newer than what is installed on the server.
  > 📘 Note
  >
  > This applies to all hosting accounts that have cPanel, including shared and reseller servers.

* You have an unmanaged server, and the package repositories for your Linux distribution contain an older version of Python.

<Warning>
  **Important**

  To complete the procedures in this article, you must first have a compiler and other development tools installed on your server. For information about how to do this, please see [Installing development tools on an unmanaged server](/docs/installing-development-tools-on-an-unmanaged-server).
</Warning>

## Configuring managed servers

Depending on the managed server where your account is located, there may be an older version of Python installed. If you want to run a newer version of Python, you can compile it from the source code.

<Warning>
  **Important**

  Although we have tested and run this configuration, it is not supported.
</Warning>

To compile Python from the source code, follow these steps:

1. Log in to your account [using SSH](/docs/using-ssh-secure-shell).

2. At the command prompt, type the following commands:

   ```bash theme={null}
   cd ~
   wget https://www.python.org/ftp/python/3.12.8/Python-3.12.8.tgz
   tar xvzf Python-3.12.8.tgz
   cd Python-3.12.8
   ./configure --prefix=$HOME
   make
   make install
   ```

   > 📘 Note
   >
   > These commands demonstrate how to install Python version 3.12.8. To install a different version, please visit [https://www.python.org/ftp/python](https://www.python.org/ftp/python) to view the versions that are available for download. After you select a version, run the previous commands with the version number you selected, instead of 3.12.8.

3. To configure your shell environment to use the new compiled executable, type the following commands. Replace ***username*** with your own hosting.com account username:

   ```bash theme={null}
   echo 'alias python3="/home/username/bin/python3.12"' > ~/.bashrc
   source ~/.bashrc
   ```

4. To confirm your account is configured to use the new version, type the following command:

   ```bash theme={null}
   python3 --version
   ```

### Using Python virtual environments

In older Python versions, you needed to install the *virtualenv* program to create and use virtual environments. With Python 3, support for virtual environments is included by default. After you install your compiled version of Python using the procedure above, you can create virtual environments immediately by using the *venv* module. For example:

```bash theme={null}
python3 -m venv testenv
```

This command creates a virtual environment named *testenv*. To activate the new environment, type the following command:

```bash theme={null}
cd testenv && source bin/activate
```

## Configuring unmanaged servers

The package repositories for your Linux distribution may contain an older version of Python. If you want to run a newer version of Python, you can compile it from the source code. To do this, follow these steps:

1. Log in to your account [using SSH](/docs/using-ssh-secure-shell).

2. As the root user, at the command prompt, type the following commands:

   ```bash theme={null}
   cd ~
   wget https://www.python.org/ftp/python/3.12.8/Python-3.12.8.tgz
   tar xvzf Python-3.12.8.tgz
   cd Python-3.12.8
   ./configure
   make
   make install
   ```

   > 📘 Note
   >
   > These commands demonstrate how to install Python version 3.12.8. To install a different version, please visit [https://www.python.org/ftp/python](https://www.python.org/ftp/python) to view the versions that are available for download. After you select a version, run the previous commands with the version number you selected, instead of 3.12.8.

3. To configure the shell environment to use the new compiled executable, type the following commands. Replace ***executable\_path*** with the path to the compiled Python executable (for example, */usr/local/bin* ):

   ```bash theme={null}
   echo 'alias python3="/executable_path/python3.12"' > ~/.bashrc
   source ~/.bashrc
   ```

4. To confirm your account is configured to use the new version, type the following command:

   ```bash theme={null}
   python3 --version
   ```

## More information

For more information about Python, please visit [https://www.python.org](https://www.python.org).
