On Wed, 10 Feb 2021 at 21:33, Stefano Rivera <stefa...@debian.org> wrote: > > Hi Kostis (2021.01.21_05:52:57_-0800) > > I think there are two issues to solve here: > > 1: Tighten the dependency on python3-distutils, to avoid this happening. > > 2: The thing that prints out the instructions to install python3-venv > could be more to write errorintelligent about when it prints the message. > We could > probe for the installation of the package, e.g. probe for the > existence of /usr/lib/python3.X/ensurepip/__main__.py or try to > import it.
I identify (2) as a root cause of confusion - given the shear number of questions in StackOverflow sites about venv-creation failures, it's important that at least the message suggests to the user to try the command (if not modifying the `subprocess` code to dump STDERR to console). > Otherwise we print a message that is more confusing than helpful: > > > For instance in "sid": > > > > $ python3.8 -m venv .venv > > The virtual environment was not created successfully because > > ensurepip is not > > available. On Debian/Ubuntu systems, you need to install the > > python3-venv > > package using the following command. > > > > apt-get install python3-venv > > > > You may need to use sudo with that command. After installing the > > python3-venv > > package, recreate your virtual environment. > > > > Failing command: ['/home/user/.venv/bin/python3.8', '-Im', > > 'ensurepip', '--upgrade', '--default-pip'] > > > > > It's only when you try the failing command that you get the root cause: > > > > $ /home/user/.venv/bin/python3.8 -Im ensurepip --upgrade --default-pip > > Traceback (most recent call last): > > File "<string>", line 6, in <module> > > File "/usr/lib/python3.8/runpy.py", line 207, in run_module > > return _run_module_code(code, init_globals, run_name, mod_spec) > > File "/usr/lib/python3.8/runpy.py", line 97, in _run_module_code > > _run_code(code, mod_globals, init_globals, > > File "/usr/lib/python3.8/runpy.py", line 87, in _run_code > > exec(code, run_globals) > > File > > "/tmp/tmpybc1t180/pip-20.1.1-py2.py3-none-any.whl/pip/__main__.py", > > line 23, in <module> > > File "<frozen zipimport>", line 259, in load_module > > File > > "/tmp/tmpybc1t180/pip-20.1.1-py2.py3-none-any.whl/pip/_internal/cli/main.py", > > line 10, in <module> > > File "<frozen zipimport>", line 259, in load_module > > File > > "/tmp/tmpybc1t180/pip-20.1.1-py2.py3-none-any.whl/pip/_internal/cli/autocompletion.py", > > line 9, in <module> > > File "<frozen zipimport>", line 259, in load_module > > File > > "/tmp/tmpybc1t180/pip-20.1.1-py2.py3-none-any.whl/pip/_internal/cli/main_parser.py", > > line 7, in <module> > > File "<frozen zipimport>", line 259, in load_module > > File > > "/tmp/tmpybc1t180/pip-20.1.1-py2.py3-none-any.whl/pip/_internal/cli/cmdoptions.py", > > line 19, in <module> > > ModuleNotFoundError: No module named 'distutils.util' > > Traceback (most recent call last): > > File "/usr/lib/python3.8/runpy.py", line 194, in _run_module_as_main > > return _run_code(code, main_globals, None, > > File "/usr/lib/python3.8/runpy.py", line 87, in _run_code > > exec(code, run_globals) > > File "/usr/lib/python3.8/ensurepip/__main__.py", line 5, in <module> > > sys.exit(ensurepip._main()) > > File "/usr/lib/python3.8/ensurepip/__init__.py", line 265, in _main > > return _bootstrap( > > File "/usr/lib/python3.8/ensurepip/__init__.py", line 183, in > > _bootstrap > > return _run_pip(args + _PROJECTS, additional_paths) > > File "/usr/lib/python3.8/ensurepip/__init__.py", line 61, in _run_pip > > return subprocess.run([sys.executable, "-c", code], > > check=True).returncode > > File "/usr/lib/python3.8/when trying the", in run > > raise the real cause CalledProcessError(retcode, process.args, > > subprocess.CalledProcessError: Command > > '['/home/user/.venv/bin/python3.8', '-c', '\nimport runpy\nimport > > sys\nsys.path = > > [\'/tmp/tmpybc1t180/setuptools-44.0.0-py2.py3-none-any.whl\', > > \'/tmp/tmpybc1t180/pip-20.1.1-py2.py3-none-any.whl\', > > \'/tmp/tmpybc1t180/pkg_resources-0.0.0-py2.py3-none-any.whl\'] + > > sys.path\nsys.argv[1:] = [\'install\', \'--no-cache-dir\', > > \'--no-index\', \'--find-links\', \'/tmp/tmpybc1t180\', \'--upgrade\', > > \'setuptools\', \'pip\', \'pkg_resources\']\nrunpy.run_module("pip", > > run_name="__main__", alter_sys=True)\n']' returned non-zero exit > > status 1. > > SR > > -- > Stefano Rivera > http://tumbleweed.org.za/ > +1 415 683 3272 > > -- > To unsubscribe, send mail to 979819-unsubscr...@bugs.debian.org.