pyenv-virtualenv
pyenv-virtualenv copied to clipboard
User level Python packages preventing virtualenv creation
Apparently have some packages installed (virtualenv in particular) prevents the creation of a virtualenv. Im not sure if its expected that virtualenv/setuptools/pip at the user/system level should be honored instead of being ignored and always installed per virtualenv but it affects the virtualenv creation per example below:
565315c85870:~# pyenv virtualenv 2.7.13 venv-2.7.13
Requirement already satisfied: virtualenv in ./.local/lib/python2.7/site-packages
pyenv: virtualenv: command not found
Installing pip from https://bootstrap.pypa.io/get-pip.py...
pyenv: version `2.7.13/envs/venv-2.7.13' is not installed (set by PYENV_VERSION environment variable)
error: failed to install pip via get-pip.py
565315c85870:~# ./.local/bin/pip2.7 uninstall virtualenv
Uninstalling virtualenv-15.1.0:
/root/.local/bin/virtualenv
/root/.local/lib/python2.7/site-packages/virtualenv-15.1.0.dist-info/DESCRIPTION.rst
/root/.local/lib/python2.7/site-packages/virtualenv-15.1.0.dist-info/INSTALLER
/root/.local/lib/python2.7/site-packages/virtualenv-15.1.0.dist-info/METADATA
/root/.local/lib/python2.7/site-packages/virtualenv-15.1.0.dist-info/RECORD
/root/.local/lib/python2.7/site-packages/virtualenv-15.1.0.dist-info/WHEEL
/root/.local/lib/python2.7/site-packages/virtualenv-15.1.0.dist-info/entry_points.txt
/root/.local/lib/python2.7/site-packages/virtualenv-15.1.0.dist-info/metadata.json
/root/.local/lib/python2.7/site-packages/virtualenv-15.1.0.dist-info/top_level.txt
/root/.local/lib/python2.7/site-packages/virtualenv.py
/root/.local/lib/python2.7/site-packages/virtualenv.pyc
/root/.local/lib/python2.7/site-packages/virtualenv_support/__init__.py
/root/.local/lib/python2.7/site-packages/virtualenv_support/__init__.pyc
/root/.local/lib/python2.7/site-packages/virtualenv_support/argparse-1.4.0-py2.py3-none-any.whl
/root/.local/lib/python2.7/site-packages/virtualenv_support/pip-9.0.1-py2.py3-none-any.whl
/root/.local/lib/python2.7/site-packages/virtualenv_support/setuptools-28.8.0-py2.py3-none-any.whl
/root/.local/lib/python2.7/site-packages/virtualenv_support/wheel-0.29.0-py2.py3-none-any.whl
Proceed (y/n)? y
Successfully uninstalled virtualenv-15.1.0
565315c85870:~# pyenv virtualenv 2.7.13 venv-2.7.13
Collecting virtualenv
Downloading virtualenv-15.1.0-py2.py3-none-any.whl (1.8MB)
100% |████████████████████████████████| 1.8MB 452kB/s
Installing collected packages: virtualenv
Successfully installed virtualenv-15.1.0
New python executable in /root/.pyenv/versions/2.7.13/envs/venv-2.7.13/bin/python2.7
Also creating executable in /root/.pyenv/versions/2.7.13/envs/venv-2.7.13/bin/python
Installing setuptools, pip, wheel...done.
Requirement already satisfied: setuptools in /root/.pyenv/versions/2.7.13/envs/venv-2.7.13/lib/python2.7/site-packages
Requirement already satisfied: pip in /root/.pyenv/versions/2.7.13/envs/venv-2.7.13/lib/python2.7/site-packages
[Edit] I think this may be something else, after I exited/re-entered the docker container it worked fine so it may be an env/loading issue.
I can confirm this issue still exists in pyenv 1.2.11-11-g7dd5014
.
Had to uninstall any .local/lib/python2.7/site-packages/virtualenv in order to get pyenv virtualenv xyz
to succeed.
I just tried pyenv and immediately got tripped by this.
Very irritating indeed :anger: :angry:
You need to add ~/.local/bin
to PATH
. In Ubuntu, this can be done by restarting the shell (its stock ~/.bashrc
only adds ~/.local/bin
to PATH
if it exists at the time of the interactive shell's start).
The core reason is that Pyenv-managed Pythons use the same user_site
path ~/.local/lib/pythonX.Y/site-packages
as the system Python. This issue is being discussed at https://github.com/pyenv/pyenv/issues/2417 .
So if you have installed virtualenv
for the system Python with Pip but not restarted the shell since, Pyenv-managed Pythons of the same <major>.<minor>
version will consider it installed -- but will not be able to invoke it because its executable in not on PATH.