Page MenuHomePhabricator

attempting to create a python virtual environment on the bastion has a confusing error message
Open, LowPublic

Description

This is the same core problem as T276626: Toolforge: Automatically identify when people are trying to launch a Python webservice with a venv created using the wrong Python version but from a different angle.

When a Toolforge user tries to create a Python virtual environment directly on the bookworm bastion, they will now get an error message instead of a virtual environment with the wrong version. This outcome, caused by the removal of packages from the bastions after the grid deprecation, is better than the previous outcome of silently creating a virtual environment that won't work, but is still confusing to new users or users unfamiliar with the Toolforge infrastructure.

tools.anticompositetest@tools-bastion-13:~$ python -m venv venv
-bash: python: command not found
tools.anticompositetest@tools-bastion-13:~$ python3 -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 install python3.11-venv

You may need to use sudo with that command.  After installing the python3-venv
package, recreate your virtual environment.

Failing command: /mnt/nfs/labstore-secondary-tools-project/anticompositetest/venv/bin/python3

Trying to run python3 -m venv on the bastions should result in an informative error message directing users to https://wikitech.wikimedia.org/wiki/Help:Toolforge/Python instead of one that asks them to do something they can't do.

Event Timeline

See also current way to create venv: T363071#9732167 although this is not obvious.

I looked briefly into this, but I don't see any ways to override this message without overriding Python stdlib files entirely which I'd rather not do.

taavi triaged this task as Low priority.May 23 2025, 9:24 AM