If you should ever encounter the following error when creating a Python
virtual environment using the pyvenv
command:
user$ pyvenv my_venv_dir
Error: Command '['/home/user/my_venv_dir/bin/python', '-Im', 'ensurepip', '--upgrade', '--default-pip']' returned non-zero exit status 1
... then the answer (below) provides a simple way to work around it, without resorting to setuptools
and it's related acrobatics.
Here's an approach that is fairly O/S agnostic...
Both the
pyvenv
andpython
commands themselves include a--without-pip
option that enable you to work around this issue; without resorting tosetuptool
or other headaches. Taking note of myinline comments
below, here's how to do it, and is very easy to understand:I hope this helps. \(◠﹏◠)/