'Issue creating python venv using python 3.9 in Ubuntu 20.04

I am having an issue with python3.9.10 on a newly downloaded instance of Ubuntu-20.04.

This is the output I get when I run python3.9 -m venv .venv:

Error: Command '['/mnt/c/.venv/bin/python3.9', '-Im', 'ensurepip', '--upgrade', '--default-pip']' returned non-zero exit status 1.

Has something changed with regard to the way python3.9 is distributed?

Historically, we used deadsnakes but we've noticed 2 things:

  1. We can install python3.9 from regular debian repository (e.g. a vanilla sudo apt-get install python3.9)
  2. All the guides seem to have changed and they talk about installing python3.9 from source (e.g. wget the tarball)

Minimal, Reproducible Problem:

After the installation of Ubuntu-20.04 through WSL2 and the creation of an initial user, the following commands were executed:

sudo apt-get update
(installation of python3.9.10 through deadsnakes)
sudo apt install software-properties-common
sudo add-apt-repository ppa:deadsnakes/ppa
sudo apt-get update
sudo apt upgrade python3.9
sudo apt upgrade python3.9 --fix-missing
(installation of python3.9-venv)
sudo apt-get install python3.9-venv
(change directory to mounted C drive)
cd /mnt/c
(Attempt to create venv)
python3.9 -m venv .venv

Additional Information

Python3.9 is installed on the machine:

Python3 running correctly on machine.

Here is the list of the installed dependencies obtained by running "apt list --installed | grep python3":

libpython3-stdlib/focal,now 3.8.2-0ubuntu2 amd64 [installed,automatic]
libpython3.8-minimal/focal-updates,focal-security,now 3.8.10-0ubuntu1~20.04.2 amd64 [installed,automatic]
libpython3.8-stdlib/focal-updates,focal-security,now 3.8.10-0ubuntu1~20.04.2 amd64 [installed,automatic]
libpython3.8/focal-updates,focal-security,now 3.8.10-0ubuntu1~20.04.2 amd64 [installed,automatic]
libpython3.9-dev/focal,now 3.9.10-1+focal1 amd64 [installed,automatic]
libpython3.9-minimal/focal,now 3.9.10-1+focal1 amd64 [installed,automatic]
libpython3.9-stdlib/focal,now 3.9.10-1+focal1 amd64 [installed,automatic]
libpython3.9/focal,now 3.9.10-1+focal1 amd64 [installed,automatic]
python3-apport/focal-updates,focal-security,now 2.20.11-0ubuntu27.21 all [installed,automatic]
python3-apt/focal-updates,now 2.0.0ubuntu0.20.04.6 amd64 [installed,automatic]
python3-attr/focal,now 19.3.0-2 all [installed,automatic]
python3-automat/focal,now 0.8.0-1ubuntu1 all [installed,automatic]
python3-blinker/focal,now 1.4+dfsg1-0.3ubuntu1 all [installed,automatic]
python3-certifi/focal,now 2019.11.28-1 all [installed,automatic]
python3-cffi-backend/focal,now 1.14.0-1build1 amd64 [installed,automatic]
python3-chardet/focal,now 3.0.4-4build1 all [installed,automatic]
python3-click/focal,now 7.0-3 all [installed,automatic]
python3-colorama/focal,now 0.4.3-1build1 all [installed,automatic]
python3-commandnotfound/focal-updates,now 20.04.5 all [installed,automatic]
python3-configobj/focal,now 5.0.6-4 all [installed,automatic]
python3-constantly/focal,now 15.1.0-1build1 all [installed,automatic]
python3-cryptography/focal-updates,focal-security,now 2.8-3ubuntu0.1 amd64 [installed,automatic]
python3-dbus/focal,now 1.2.16-1build1 amd64 [installed,automatic]
python3-debconf/focal,now 1.5.73 all [installed,automatic]
python3-debian/focal,now 0.1.36ubuntu1 all [installed,automatic]
python3-distro-info/focal,now 0.23ubuntu1 all [installed,automatic]
python3-distro/focal,now 1.4.0-1 all [installed,automatic]
python3-distupgrade/focal-updates,now 1:20.04.36 all [installed,automatic]
python3-distutils/focal-updates,focal-security,now 3.8.10-0ubuntu1~20.04 all [installed]
python3-entrypoints/focal,now 0.3-2ubuntu1 all [installed,automatic]
python3-gdbm/focal-updates,focal-security,now 3.8.10-0ubuntu1~20.04 amd64 [installed,automatic]
python3-gi/focal,now 3.36.0-1 amd64 [installed,automatic]
python3-hamcrest/focal,now 1.9.0-3 all [installed,automatic]
python3-httplib2/focal,now 0.14.0-1ubuntu1 all [installed,automatic]
python3-hyperlink/focal,now 19.0.0-1 all [installed,automatic]
python3-idna/focal,now 2.8-1 all [installed,automatic]
python3-importlib-metadata/focal,now 1.5.0-1 all [installed]
python3-incremental/focal,now 16.10.1-3.2 all [installed,automatic]
python3-jinja2/focal,now 2.10.1-2 all [installed]
python3-json-pointer/focal,now 2.0-0ubuntu1 all [installed]
python3-jsonpatch/focal,now 1.23-3 all [installed]
python3-jwt/focal,now 1.7.1-2ubuntu2 all [installed,automatic]
python3-keyring/focal,now 18.0.1-2ubuntu1 all [installed,automatic]
python3-launchpadlib/focal,now 1.10.13-1 all [installed,automatic]
python3-lazr.restfulclient/focal,now 0.14.2-2build1 all [installed,automatic]
python3-lazr.uri/focal,now 1.0.3-4build1 all [installed,automatic]
python3-lib2to3/focal-updates,focal-security,now 3.8.10-0ubuntu1~20.04 all [installed]
python3-markupsafe/focal,now 1.1.0-1build2 amd64 [installed]
python3-minimal/focal,now 3.8.2-0ubuntu2 amd64 [installed,automatic]
python3-more-itertools/focal,now 4.2.0-1build1 all [installed]
python3-nacl/focal,now 1.3.0-5 amd64 [installed]
python3-netifaces/focal,now 0.10.4-1ubuntu4 amd64 [installed,automatic]
python3-newt/focal,now 0.52.21-4ubuntu2 amd64 [installed,automatic]
python3-oauthlib/focal,now 3.1.0-1ubuntu2 all [installed,automatic]
python3-openssl/focal,now 19.0.0-1build1 all [installed,automatic]
python3-pexpect/focal,now 4.6.0-1build1 all [installed,automatic]
python3-pkg-resources/focal,now 45.2.0-1 all [installed,automatic]
python3-problem-report/focal-updates,focal-security,now 2.20.11-0ubuntu27.21 all [installed,automatic]
python3-ptyprocess/focal,now 0.6.0-1ubuntu1 all [installed,automatic]
python3-pyasn1-modules/focal,now 0.2.1-0.2build1 all [installed,automatic]
python3-pyasn1/focal,now 0.4.2-3build1 all [installed,automatic]
python3-pymacaroons/focal,now 0.13.0-3 all [installed]
python3-pyrsistent/focal,now 0.15.5-1build1 amd64 [installed]
python3-requests-unixsocket/focal,now 0.2.0-2 all [installed,automatic]
python3-requests/focal,now 2.22.0-2ubuntu1 all [installed,automatic]
python3-secretstorage/focal,now 2.3.1-2ubuntu1 all [installed,automatic]
python3-serial/focal,now 3.4-5.1 all [installed]
python3-service-identity/focal,now 18.1.0-5build1 all [installed,automatic]
python3-simplejson/focal,now 3.16.0-2ubuntu2 amd64 [installed,automatic]
python3-six/focal,now 1.14.0-2 all [installed,automatic]
python3-software-properties/focal-updates,now 0.99.9.8 all [installed,automatic]
python3-systemd/focal,now 234-3build2 amd64 [installed,automatic]
python3-twisted-bin/focal-updates,now 18.9.0-11ubuntu0.20.04.1 amd64 [installed,automatic]
python3-twisted/focal-updates,now 18.9.0-11ubuntu0.20.04.1 all [installed,automatic]
python3-update-manager/focal-updates,now 1:20.04.10.9 all [installed,automatic]
python3-urllib3/focal-updates,focal-security,now 1.25.8-2ubuntu0.1 all [installed,automatic]
python3-wadllib/focal,now 1.3.3-3build1 all [installed,automatic]
python3-yaml/focal-updates,focal-security,now 5.3.1-1ubuntu0.1 amd64 [installed,automatic]
python3-zipp/focal,now 1.0.0-1 all [installed]
python3-zope.interface/focal,now 4.7.1-1 amd64 [installed,automatic]
python3.8-minimal/focal-updates,focal-security,now 3.8.10-0ubuntu1~20.04.2 amd64 [installed,automatic]
python3.8/focal-updates,focal-security,now 3.8.10-0ubuntu1~20.04.2 amd64 [installed,automatic]
python3.9-dev/focal,now 3.9.10-1+focal1 amd64 [installed]
python3.9-minimal/focal,now 3.9.10-1+focal1 amd64 [installed,automatic]
python3.9-venv/focal,now 3.9.10-1+focal1 amd64 [installed]
python3.9/focal,now 3.9.10-1+focal1 amd64 [installed]
python3/focal,now 3.8.2-0ubuntu2 amd64 [installed,automatic]

Also, the following is the output I get when running "python3.9 -Im ensurepip --upgrade --default-pip -vvv":

Using pip 21.2.4 from /tmp/tmpw8ou6zai/pip-21.2.4-py3-none-any.whl/pip (python 3.9)
Defaulting to user installation because normal site-packages is not writeable
Ignoring indexes: https://pypi.org/simple
Created temporary directory: /tmp/pip-ephem-wheel-cache-rf_gtlif
Created temporary directory: /tmp/pip-req-tracker-bfrozg9l
Initialized build tracking at /tmp/pip-req-tracker-bfrozg9l
Created build tracker: /tmp/pip-req-tracker-bfrozg9l
Entered build tracker: /tmp/pip-req-tracker-bfrozg9l
Created temporary directory: /tmp/pip-install-98di96k3
Looking in links: /tmp/tmpw8ou6zai
Requirement already satisfied: setuptools in /home/dylan/.local/lib/python3.9/site-packages (58.1.0)
0 location(s) to search for versions of setuptools:
Found link file:///tmp/tmpw8ou6zai/setuptools-58.1.0-py3-none-any.whl, version: 58.1.0
Skipping link: wrong project name (not setuptools): file:///tmp/tmpw8ou6zai/pip-21.2.4-py3-none-any.whl
Local files found: /tmp/tmpw8ou6zai/setuptools-58.1.0-py3-none-any.whl
Given no hashes to check 1 links for project 'setuptools': discarding no candidates
Requirement already satisfied: pip in /home/dylan/.local/lib/python3.9/site-packages (21.2.4)
0 location(s) to search for versions of pip:
Skipping link: wrong project name (not pip): file:///tmp/tmpw8ou6zai/setuptools-58.1.0-py3-none-any.whl
Found link file:///tmp/tmpw8ou6zai/pip-21.2.4-py3-none-any.whl, version: 21.2.4
Local files found: /tmp/tmpw8ou6zai/pip-21.2.4-py3-none-any.whl
Given no hashes to check 1 links for project 'pip': discarding no candidates
Created temporary directory: /tmp/pip-unpack-usxae_m7
Removed build tracker: '/tmp/pip-req-tracker-bfrozg9l'


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source