4

I have installed python 3.10 on Ubuntu 20.04 using the deadsnakes ppa. It works. However trying to create a venv with it fails:

$ python3.10 -m venv venv3.10

Error: Command '['<my-working-directory>/venv3.10/bin/python3.10', '-m', 'ensurepip', '--upgrade', '--default-pip']' returned non-zero exit status 1.

This is quite similar to a similar question regardgin python 3.11, there was also something similar regarding older versions. However the installation of pip is not a solution because it will be an issue later on, if only for being able to use the new venv in PyCharm which currently fails over missing setuptools. I have already upgraded to the latest version of pip, as some related issues mention. I also did manage re-installing pip as if for/with version 3.10,

$ curl -sS https://bootstrap.pypa.io/get-pip.py | python3.10

And I am getting this version information for it:

$ python3.10 -m pip --version
pip 23.1 from /home/matan/.local/lib/python3.10/site-packages/pip (python 3.10)

But trying to create a new python 3.10 venv using python 3.10 just ends up with the originally above mentioned error message. As if venv and/or pip are not fully integrated or something locally is pointing at old artifacts for python 3.10.

matanster
  • 15,072
  • 19
  • 88
  • 167
  • have you tried rerunning the command to install the virtual env on ubuntu? `sudo apt install python3-venv` – kyrlon Apr 23 '23 at 13:41
  • 1
    I have now, and it fetches `python3.8-venv` and the error is the same after that. And I shouldn't have tried this because it could only destabilize my working earlier (3.8) python environments if anything. But then I tried `sudo apt install python3.10-venv` and the problem is solved. I was not aware it needs or can be separately installed after installing python 3.10 from deadsnakes. Problem solved. – matanster Apr 24 '23 at 19:41
  • You can make that an answer to get the bounty BTW! – matanster Apr 25 '23 at 06:36

1 Answers1

4

Running sudo apt install python3.10-venv installs the virtual environment package for python 3.10, which you otherwise are not getting when just installing python 3.10 itself from deadsnakes.

To verify this, I downloaded a brand-new copy of Ubuntu 20.04 LTS for my VirtualBox and used the procedures listed below:

sudo add-apt-repository ppa:deadsnakes/ppa
sudo apt-get update
sudo apt-get install python3.10 python3.10-venv

Afterwards creating a virtual environment for python 3.10 is possible:

kyrlon@pc23:~$ python3.10 -m venv py_venv
kyrlon@pc23:~$ source py_venv/bin/activate
(py_venv) kyrlon@pc23:~$

As stated in the packages section of the main PPA page for deadsnakes

the packages follow debian's patterns and often do not include a full python distribution with just apt install python#.#

When using the command apt install python3.10, the python virtual environment package for python 3.10 (venv), as well as other useful packages dev, distutils, lib2to3, gdbm, and tk, are not included. As mentioned from the PPA page, apt install python#.# (with # representing the version of python in that instance) is not an all in one python distribution since they follow debian's packaging pattern/practice.

Stated in 6.1.3. Multiple binary packages

A single source package will often build several binary packages, either to provide several flavors of the same software (e.g., the vim source package) or to make several small packages instead of a big one (e.g., so the user can install only the subset needed, and thus save some disk space, see for example the lyx source package).

Given such context, it is understandable why it was left out. As mentioned above, since the user has the option to install particular packages, they can avoid the bloat of packages they do not need for their use case.

Hopefully this clears up to users (including myself) that running apt install python3 does not install venv or other beneficial packages as one encompassing distribution from the deadsnakes PPA, as you could see from a binary package as offered for Windows OS.

kyrlon
  • 1,065
  • 2
  • 8
  • 16