virtualenv icon indicating copy to clipboard operation
virtualenv copied to clipboard

Support Pythons without distutils

Open gaborbernat opened this issue 4 years ago • 6 comments

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.

gaborbernat avatar Jul 29 '20 14:07 gaborbernat

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.

hynek avatar Dec 11 '20 06:12 hynek

FYi https://bugs.launchpad.net/ubuntu/+source/python-distutils-extra/+bug/1892159

jamesjjcondon avatar Feb 23 '21 02:02 jamesjjcondon

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) image

machine b) image

Any pointers @gaborbernat ?

jamesjjcondon avatar Feb 23 '21 03:02 jamesjjcondon

Don't know how but removing and purging python3.7 and reinstalling from deadsnakes seems to have fixed

jamesjjcondon avatar Feb 23 '21 03:02 jamesjjcondon

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

freundTech avatar Mar 16 '21 16:03 freundTech

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

urkh avatar Apr 14 '21 01:04 urkh

This has been done now.

gaborbernat avatar Jun 27 '23 03:06 gaborbernat