virtualenv
virtualenv copied to clipboard
Support Pythons without distutils
At the moment interpreter lookup fails when distutils
is not available, e.g. on some Ubuntu Python distributions. Error:
113 failed to query /usr/bin/python3.6 with code 1 err: 'Traceback (most recent call last):\n File "/home/manos/.local/lib/python3.8/site-packages/virtualenv/discovery/py_info.py", line 16, in <module>\n from distutils.command.install import SCHEME_KEYS\nModuleNotFoundError: No module named \'distutils.command\'\n' [INFO cached_py_info:38]
See https://github.com/pypa/virtualenv/issues/1643#issuecomment-665691388.
To help desperate Googlers (me, yesterday): if you get RuntimeError: failed to find interpreter for Builtin discover of python_spec='3.9'
on Ubuntu or debian and you positively know that the interpreter is installed, it might be that you're missing python3.9-distutils
.
FYi https://bugs.launchpad.net/ubuntu/+source/python-distutils-extra/+bug/1892159
I'm having a similar issue trying to create a virtualenv with python3.7 on Ubuntu 20.04. Not missing python3.9-distutils. and python3.7-distutils not available. Above didn't help.
Have got working on machine a) but not b). verbose traces below. Seems to be related to cpython version and proposed python path.
machine a)
machine b)
Any pointers @gaborbernat ?
Don't know how but removing and purging python3.7 and reinstalling from deadsnakes seems to have fixed
Note that python 3.10 will deprecate distutils. Python 3.12 will completely remove it. See https://docs.python.org/3.10/whatsnew/3.10.html#distutils-deprecated
For those who have a similar problem with python3.7 or lower and use a .deb distro, the solution is to install the python*-distutils
package according to the version of python that is failing. A quick and easy option is to add deadsnakes ppa and from there install the required python version along with distutils
https://launchpad.net/~deadsnakes/+archive/ubuntu/ppa
This has been done now.