What happens, I believe, is that --relocatable prepends some code to all
files in <venv>/bin to run activate_this.py, which in turn changes
sys.prefix (the grandparent directory of Python libraries, normally
something like /usr) to point to the venv and saves the old value in
sys.real_prefix. When you run activate and then you run pip, this code is
called twice, and the second time sys.real_prefix is overwritten with the
old value of sys.prefix which at this point is also the venv. This will
then fail the assertion in pip which verifies that real_prefix points to
the system-wide Python installation.

Workaround is to run pip from the interpreter, without invoking the
executable:

python -c "import pip; pip.main(['install', 'flask'])"

(Running  <venv>/bin/pip while the venv is not activated would probably
work as well.)

Reply via email to