'Trying to use pipenv on fresh ubuntu install, does not allow me to use python 3.10

I'm trying to figure out how to properly use pipenv. I have a fresh Ubuntu 20.04.4 LTS install.

I installed pipenv

$sudo apt install pipenv

And it seems I can successfully create a virtual environment by running

$ pipenv --python 3.8

However, I tried to create an environment for python 3.10 and at first it failed because it could not find python 3.10 on my system.

Python 3.10 was not found on your system... You can specify specific versions of Python with: $ pipenv --python path/to/python

So I installed 3.10 like this:

$sudo add-apt-repository ppa:deadsnakes/ppa
$sudo apt install python3.10
$which python3.10
$/usr/bin/python3.10

I should now have python 3.10 on my system, I now try

$pipenv --python /usr/bin/python3.10

And now I get all this:

Creating a virtualenv for this project…

Using /usr/bin/python3.10 (3.10.2) to create virtualenv…

⠋RuntimeError: failed to query /usr/bin/python3.10 with code 1 err: '/usr/lib/python3/dist-packages/virtualenv/discovery/py_info.py:16: DeprecationWarning: The distutils package is deprecated and slated for removal in Python 3.12. Use setuptools or check PEP 632 for potential alternatives\n from distutils.command.install import SCHEME_KEYS\nTraceback (most recent call last):\n File "/usr/lib/python3/dist-packages/virtualenv/discovery/py_info.py", line 16, in \n from distutils.command.install import SCHEME_KEYS\nModuleNotFoundError: No module named 'distutils.command'\n' Error while trying to remove the /home/balmes/.local/share/virtualenvs/test-p0eTKeXl env: No such file or directory

Virtualenv location:

Warning: Your Pipfile requires python_version 3.8, but you are using None (/bin/python). $ pipenv check will surely fail.

Can somebody please explain what's going on? Thanks!!!



Sources

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

Source: Stack Overflow

Solution Source