<div dir="ltr"><div>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.</div><div><br></div>Workaround is to run pip from the interpreter, without invoking the executable:<div><br></div><div>python -c "import pip; pip.main(['install', '<span style="color:rgb(0,0,0);line-height:19.2px">flask</span>'])"</div><div><div><br></div></div><div>(Running Â <venv>/bin/pip while the venv is not activated would probably work as well.)</div></div>