Skip to main content
added 29 characters in body
Source Link
Seth Falco
  • 188
  • 1
  • 11

OnSince Debian Trixie (Testing, at the time of answering) and Ubuntu 25.04 (non-LTS), one can do this using pyenv and venv, both packages are already available in the Debiandistribution's repositories. No manual installation or PPA necessary. These steps should work on Ubuntu as well.

I believe the following steps require a host Python version of >=3.3, as venv is only supported from Python v3.3.

Required Packages

Install pyenv and venv from the Debian repositories:

sudo apt-get install -y \
  pyenv \
  python3-venv

Install Python Version

Install the desired Python version using pyenv, I hope no one needs this information, but it does support Python v2 as well:

pyenv install 3.11

This method of installing alternate Python versions will not conflict with your distributions packages.

Create Virtual Environment

Use the Python binary that pyenv installed for you, and invoke the venv module to create a new virtual environment. In my case I use Python v3.11, but you can use whatever you need.

~/.pyenv/versions/3.11.11/bin/python3.11 -m venv .venv
source .venv/bin/activate

Usage

Now that the virtual environment has been activated, you'll find that python3.11 and pip3.11 are on your PATH. You can use these as you would normally do with python3 or if you were using the Ubuntu PPA.

For example:

pip3.11 install -r requirements.txt

pyenv vs. Ubuntu's deadsnakes PPA

Ubuntu's deadsnakes PPA will add newly installed binaries to your PATH by default. So upon installing a version of Python, it'll be immediately available as python3.11 for example.

Using pyenv, versions are installed to ~/.pyenv/versions/3.11.11 and are not in your PATH. You can either add them yourself with a symlink:

sudo ln -s ~/.pyenv/versions/3.11.11/bin/python3.11/bin/python3.11 /usr/bin/python3.11
sudo ln -s ~/.pyenv/versions/3.11.11/bin/python3.11/bin/pip3.11 /usr/bin/pip3.11

(I propose symlinking the suffixed files rather than simply adding ~/.pyenv/versions/3.11.11 to your PATH, because this directory also contains binaries like python and python3. These names overlap with the hosts installations binaries.)

Or you can specify the full path when setting up your virtual environment with venv, and the binaries with the 3.11 suffix will automatically be added to your PATH while the virtual environment is active.


Attribution: This answer is based on How to Properly Manage Multiple Python Versions, authored by Javier Lobato Perez, and published on Baeldung.

On Debian Trixie (Testing, at the time of answering), one can do this using pyenv and venv, both packages are already available in the Debian repositories. No manual installation or PPA necessary. These steps should work on Ubuntu as well.

I believe the following steps require a host Python version of >=3.3, as venv is only supported from Python v3.3.

Required Packages

Install pyenv and venv from the Debian repositories:

sudo apt-get install -y \
  pyenv \
  python3-venv

Install Python Version

Install the desired Python version using pyenv, I hope no one needs this information, but it does support Python v2 as well:

pyenv install 3.11

This method of installing alternate Python versions will not conflict with your distributions packages.

Create Virtual Environment

Use the Python binary that pyenv installed for you, and invoke the venv module to create a new virtual environment. In my case I use Python v3.11, but you can use whatever you need.

~/.pyenv/versions/3.11.11/bin/python3.11 -m venv .venv
source .venv/bin/activate

Usage

Now that the virtual environment has been activated, you'll find that python3.11 and pip3.11 are on your PATH. You can use these as you would normally do with python3 or if you were using the Ubuntu PPA.

For example:

pip3.11 install -r requirements.txt

pyenv vs. Ubuntu's deadsnakes PPA

Ubuntu's deadsnakes PPA will add newly installed binaries to your PATH by default. So upon installing a version of Python, it'll be immediately available as python3.11 for example.

Using pyenv, versions are installed to ~/.pyenv/versions/3.11.11 and are not in your PATH. You can either add them yourself with a symlink:

sudo ln -s ~/.pyenv/versions/3.11.11/bin/python3.11/bin/python3.11 /usr/bin/python3.11
sudo ln -s ~/.pyenv/versions/3.11.11/bin/python3.11/bin/pip3.11 /usr/bin/pip3.11

(I propose symlinking the suffixed files rather than simply adding ~/.pyenv/versions/3.11.11 to your PATH, because this directory also contains binaries like python and python3. These names overlap with the hosts installations binaries.)

Or you can specify the full path when setting up your virtual environment with venv, and the binaries with the 3.11 suffix will automatically be added to your PATH while the virtual environment is active.


Attribution: This answer is based on How to Properly Manage Multiple Python Versions, authored by Javier Lobato Perez, and published on Baeldung.

Since Debian Trixie (Testing at the time of answering) and Ubuntu 25.04 (non-LTS), one can do this using pyenv and venv, both packages are already available in the distribution's repositories. No manual installation or PPA necessary.

I believe the following steps require a host Python version of >=3.3, as venv is only supported from Python v3.3.

Required Packages

Install pyenv and venv from the Debian repositories:

sudo apt-get install -y \
  pyenv \
  python3-venv

Install Python Version

Install the desired Python version using pyenv, I hope no one needs this information, but it does support Python v2 as well:

pyenv install 3.11

This method of installing alternate Python versions will not conflict with your distributions packages.

Create Virtual Environment

Use the Python binary that pyenv installed for you, and invoke the venv module to create a new virtual environment. In my case I use Python v3.11, but you can use whatever you need.

~/.pyenv/versions/3.11.11/bin/python3.11 -m venv .venv
source .venv/bin/activate

Usage

Now that the virtual environment has been activated, you'll find that python3.11 and pip3.11 are on your PATH. You can use these as you would normally do with python3 or if you were using the Ubuntu PPA.

For example:

pip3.11 install -r requirements.txt

pyenv vs. Ubuntu's deadsnakes PPA

Ubuntu's deadsnakes PPA will add newly installed binaries to your PATH by default. So upon installing a version of Python, it'll be immediately available as python3.11 for example.

Using pyenv, versions are installed to ~/.pyenv/versions/3.11.11 and are not in your PATH. You can either add them yourself with a symlink:

sudo ln -s ~/.pyenv/versions/3.11.11/bin/python3.11/bin/python3.11 /usr/bin/python3.11
sudo ln -s ~/.pyenv/versions/3.11.11/bin/python3.11/bin/pip3.11 /usr/bin/pip3.11

(I propose symlinking the suffixed files rather than simply adding ~/.pyenv/versions/3.11.11 to your PATH, because this directory also contains binaries like python and python3. These names overlap with the hosts installations binaries.)

Or you can specify the full path when setting up your virtual environment with venv, and the binaries with the 3.11 suffix will automatically be added to your PATH while the virtual environment is active.


Attribution: This answer is based on How to Properly Manage Multiple Python Versions, authored by Javier Lobato Perez, and published on Baeldung.

added 824 characters in body
Source Link
Seth Falco
  • 188
  • 1
  • 11

YouOn Debian Trixie (Testing, at the time of answering), one can do this using pyenv and venv, both packages are already available in the Debian repositories. No manual installation or PPA necessary. These steps should work on Ubuntu as well.

I believe the following steps require a host Python version of >=3.3, as venv is only supported from Python v3.3.

Required Packages

Install pyenv and venv from the Debian repositories:

sudo apt-get install -y \
  pyenv \
  python3-venv

Install Python Version

Install the desired Python version using pyenv, I hope no one needs this information, but it does support Python v2 as well:

pyenv install 3.11

This method of installing alternate Python versions will not conflict with your distributions packages.

Create Virtual Environment

Use the Python binary that pyenv installed for you, and invoke the venv module to create a new virtual environment. In my case I use Python v3.11, but you can use whatever you need.

~/.pyenv/versions/3.11.11/bin/python3.11 -m venv .venv
source .venv/bin/activate

Usage

Now that the virtual environment has been activated, you'll find that python3.11 and pip3.11 are on your PATH. You can use these as you would normally do with python3 or if you were using the Ubuntu PPA.

For example:

pip3.11 install -r requirements.txt

pyenv vs. Ubuntu's deadsnakes PPA

Ubuntu's deadsnakes PPA will add newly installed binaries to your PATH by default. So upon installing a version of Python, it'll be immediately available as python3.11 for example.

Using pyenv, versions are installed to ~/.pyenv/versions/3.11.11 and are not in your PATH. You can either add them yourself with a symlink:

sudo ln -s ~/.pyenv/versions/3.11.11/bin/python3.11/bin/python3.11 /usr/bin/python3.11
sudo ln -s ~/.pyenv/versions/3.11.11/bin/python3.11/bin/pip3.11 /usr/bin/pip3.11

(I propose symlinking the suffixed files rather than simply adding ~/.pyenv/versions/3.11.11 to your PATH, because this directory also contains binaries like python and python3. These names overlap with the hosts installations binaries.)

Or you can specify the full path when setting up your virtual environment with venv, and the binaries with the 3.11 suffix will automatically be added to your PATH while the virtual environment is activatedactive.


Attribution: This answer is based on How to Properly Manage Multiple Python Versions, authored by Javier Lobato Perez, and published on Baeldung.

You can do this using pyenv and venv, both packages are already available in the Debian repositories. No manual installation or PPA necessary. These steps should work on Ubuntu as well.

I believe the following steps require a host Python version of >=3.3, as venv is only supported from Python v3.3.

Required Packages

Install pyenv and venv from the Debian repositories:

sudo apt-get install -y \
  pyenv \
  python3-venv

Install Python Version

Install the desired Python version using pyenv, I hope no one needs this information, but it does support Python v2 as well:

pyenv install 3.11

This method of installing alternate Python versions will not conflict with your distributions packages.

Create Virtual Environment

Use the Python binary that pyenv installed for you, and invoke the venv module to create a new virtual environment. In my case I use Python v3.11, but you can use whatever you need.

~/.pyenv/versions/3.11.11/bin/python3.11 -m venv .venv
source .venv/bin/activate

Usage

Now that the virtual environment has been activated, you'll find that python3.11 and pip3.11 are on your PATH. You can use these as you would normally do with python3 or if you were using the Ubuntu PPA.

For example:

pip3.11 install -r requirements.txt

pyenv vs. Ubuntu's deadsnakes PPA

Ubuntu's deadsnakes PPA will add newly installed binaries to your PATH by default. So upon installing a version of Python, it'll be immediately available as python3.11 for example.

Using pyenv, versions are installed to ~/.pyenv/versions/3.11.11 and are not in your PATH. You can either add them yourself with a symlink:

sudo ln -s ~/.pyenv/versions/3.11.11/bin/python3.11/bin/python3.11 /usr/bin/python3.11
sudo ln -s ~/.pyenv/versions/3.11.11/bin/python3.11/bin/pip3.11 /usr/bin/pip3.11

(I propose symlinking the suffixed files rather than simply adding ~/.pyenv/versions/3.11.11 to your PATH, because this directory also contains binaries like python and python3. These names overlap with the hosts installations binaries.)

Or you can specify the full path when setting up your virtual environment with venv, and the binaries with the 3.11 suffix will automatically be added to your PATH while the virtual environment is activated.


Attribution: This answer is based on How to Properly Manage Multiple Python Versions, authored by Javier Lobato Perez, and published on Baeldung.

On Debian Trixie (Testing, at the time of answering), one can do this using pyenv and venv, both packages are already available in the Debian repositories. No manual installation or PPA necessary. These steps should work on Ubuntu as well.

I believe the following steps require a host Python version of >=3.3, as venv is only supported from Python v3.3.

Required Packages

Install pyenv and venv from the Debian repositories:

sudo apt-get install -y \
  pyenv \
  python3-venv

Install Python Version

Install the desired Python version using pyenv, I hope no one needs this information, but it does support Python v2 as well:

pyenv install 3.11

This method of installing alternate Python versions will not conflict with your distributions packages.

Create Virtual Environment

Use the Python binary that pyenv installed for you, and invoke the venv module to create a new virtual environment. In my case I use Python v3.11, but you can use whatever you need.

~/.pyenv/versions/3.11.11/bin/python3.11 -m venv .venv
source .venv/bin/activate

Usage

Now that the virtual environment has been activated, you'll find that python3.11 and pip3.11 are on your PATH. You can use these as you would normally do with python3 or if you were using the Ubuntu PPA.

For example:

pip3.11 install -r requirements.txt

pyenv vs. Ubuntu's deadsnakes PPA

Ubuntu's deadsnakes PPA will add newly installed binaries to your PATH by default. So upon installing a version of Python, it'll be immediately available as python3.11 for example.

Using pyenv, versions are installed to ~/.pyenv/versions/3.11.11 and are not in your PATH. You can either add them yourself with a symlink:

sudo ln -s ~/.pyenv/versions/3.11.11/bin/python3.11/bin/python3.11 /usr/bin/python3.11
sudo ln -s ~/.pyenv/versions/3.11.11/bin/python3.11/bin/pip3.11 /usr/bin/pip3.11

(I propose symlinking the suffixed files rather than simply adding ~/.pyenv/versions/3.11.11 to your PATH, because this directory also contains binaries like python and python3. These names overlap with the hosts installations binaries.)

Or you can specify the full path when setting up your virtual environment with venv, and the binaries with the 3.11 suffix will automatically be added to your PATH while the virtual environment is active.


Attribution: This answer is based on How to Properly Manage Multiple Python Versions, authored by Javier Lobato Perez, and published on Baeldung.

added 824 characters in body
Source Link
Seth Falco
  • 188
  • 1
  • 11

You can do this using pyenv and venv, both packages are already available in the Debian repositories. No manual installation or PPA necessary. These steps should work on Ubuntu as well.

I believe the following steps will only work if usingrequire a host Python version of >=3.3, as venv is only supported from Python v3.3.

Required Packages

Install pyenv and venv from the Debian repositories:

sudo apt-get install -y \
  pyenv \
  python3-venv

Install Python Version

Install the desired Python version using pyenv, I hope no one needs this information, but it does support Python v2 as well:

pyenv install 3.11

This method of installing alternate Python versions will not conflict with your distributions packages.

Create Virtual Environment

Use the Python binary that pyenv installed for you, and invoke the venv module to create a new virtual environment. In my case I use Python v3.11, but you can use whatever you need.

~/.pyenv/versions/3.11.11/bin/python3.11 -m venv .venv
source .venv/bin/activate

Usage

Now that the virtual environment has been activated, you'll find that python3.11 and pip3.11 are on your PATH. You can use these as you would normally do with python3 or if you were using the Ubuntu PPA.

For example:

pip3.11 install -r requirements.txt

pyenv vs. Ubuntu's deadsnakes PPA

Ubuntu's deadsnakes PPA will add newly installed binaries to your PATH by default. So upon installing a version of Python, it'll be immediately available as python3.11 for example.

Using pyenv, versions are installed to ~/.pyenv/versions/3.11.11 and are not in your PATH. You can either add them yourself with a symlink:

sudo ln -s ~/.pyenv/versions/3.11.11/bin/python3.11/bin/python3.11 /usr/bin/python3.11
sudo ln -s ~/.pyenv/versions/3.11.11/bin/python3.11/bin/pip3.11 /usr/bin/pip3.11

(I propose symlinking the suffixed files rather than simply adding ~/.pyenv/versions/3.11.11 to your PATH, because this directory also contains binaries like python and python3. These names overlap with the hosts installations binaries.)

Or you can specify the full path when setting up your virtual environment with venv, and the binaries with the 3.11 suffix will automatically be added to your PATH while the virtual environment is activated.


Attribution: This answer is based on How to Properly Manage Multiple Python Versions, authored by Javier Lobato Perez, and published on Baeldung.

You can do this using pyenv and venv, both packages already available in the Debian repositories. No manual installation or PPA necessary. These steps should work on Ubuntu as well.

I believe the following steps will only work if using a host Python version of >=3.3, as venv is only supported from Python v3.3.

Required Packages

Install pyenv and venv from the Debian repositories:

sudo apt-get install -y \
  pyenv \
  python3-venv

Install Python Version

Install the desired Python version using pyenv, I hope no one needs this information, but it does support Python v2 as well:

pyenv install 3.11

This method of installing alternate Python versions will not conflict with your distributions packages.

Create Virtual Environment

Use the Python binary that pyenv installed for you, and invoke the venv module to create a new virtual environment. In my case I use Python v3.11, but you can use whatever you need.

~/.pyenv/versions/3.11.11/bin/python3.11 -m venv .venv
source .venv/bin/activate

Usage

Now that the virtual environment has been activated, you'll find that python3.11 and pip3.11 are on your PATH. You can use these as you would normally do with python3 or if you were using the Ubuntu PPA.

For example:

pip3.11 install -r requirements.txt

pyenv vs. Ubuntu's deadsnakes PPA

Ubuntu's deadsnakes PPA will add newly installed binaries to your PATH by default. So upon installing a version of Python, it'll be immediately available as python3.11 for example.

Using pyenv, versions are installed to ~/.pyenv/versions/3.11.11 and are not in your PATH. You can either add them yourself with a symlink:

sudo ln -s ~/.pyenv/versions/3.11.11/bin/python3.11/bin/python3.11 /usr/bin/python3.11
sudo ln -s ~/.pyenv/versions/3.11.11/bin/python3.11/bin/pip3.11 /usr/bin/pip3.11

Or you can specify the full path when setting up your virtual environment with venv, and the binaries with the 3.11 suffix will automatically be added to your PATH while the virtual environment is activated.


Attribution: This answer is based on How to Properly Manage Multiple Python Versions, authored by Javier Lobato Perez, and published on Baeldung.

You can do this using pyenv and venv, both packages are already available in the Debian repositories. No manual installation or PPA necessary. These steps should work on Ubuntu as well.

I believe the following steps require a host Python version of >=3.3, as venv is only supported from Python v3.3.

Required Packages

Install pyenv and venv from the Debian repositories:

sudo apt-get install -y \
  pyenv \
  python3-venv

Install Python Version

Install the desired Python version using pyenv, I hope no one needs this information, but it does support Python v2 as well:

pyenv install 3.11

This method of installing alternate Python versions will not conflict with your distributions packages.

Create Virtual Environment

Use the Python binary that pyenv installed for you, and invoke the venv module to create a new virtual environment. In my case I use Python v3.11, but you can use whatever you need.

~/.pyenv/versions/3.11.11/bin/python3.11 -m venv .venv
source .venv/bin/activate

Usage

Now that the virtual environment has been activated, you'll find that python3.11 and pip3.11 are on your PATH. You can use these as you would normally do with python3 or if you were using the Ubuntu PPA.

For example:

pip3.11 install -r requirements.txt

pyenv vs. Ubuntu's deadsnakes PPA

Ubuntu's deadsnakes PPA will add newly installed binaries to your PATH by default. So upon installing a version of Python, it'll be immediately available as python3.11 for example.

Using pyenv, versions are installed to ~/.pyenv/versions/3.11.11 and are not in your PATH. You can either add them yourself with a symlink:

sudo ln -s ~/.pyenv/versions/3.11.11/bin/python3.11/bin/python3.11 /usr/bin/python3.11
sudo ln -s ~/.pyenv/versions/3.11.11/bin/python3.11/bin/pip3.11 /usr/bin/pip3.11

(I propose symlinking the suffixed files rather than simply adding ~/.pyenv/versions/3.11.11 to your PATH, because this directory also contains binaries like python and python3. These names overlap with the hosts installations binaries.)

Or you can specify the full path when setting up your virtual environment with venv, and the binaries with the 3.11 suffix will automatically be added to your PATH while the virtual environment is activated.


Attribution: This answer is based on How to Properly Manage Multiple Python Versions, authored by Javier Lobato Perez, and published on Baeldung.

added 824 characters in body
Source Link
Seth Falco
  • 188
  • 1
  • 11
Loading
Source Link
Seth Falco
  • 188
  • 1
  • 11
Loading