Cross posting the issue from #1015 in pyenv repo because this is the same bug but also affects pyenv-virtualenv. It is rather frustrating.
I have the following in my .bashrc on Ubuntu 16.06:
eval "$(pyenv init -)"
eval "$(pyenv virtualenv-init -)"
the pip executable being used does not change along with the python version upon evoking pyenv active <virtualenv> or deactivate for both system installs and pyenv installs alike.
Evoking eval "$(pyenv init -)" directly results in the pip executable updating as appropriate. However, changing back into or out of a virtualenv with undo this. In my situation, it is defaulting to a pip for pyenv python version I installed, Python 3.5.2.
Here is the observed behavior:
๐ โ python --version
Python 2.7.12
๐ โ python3 --version
Python 3.5.2
๐ โ pip --version
pip 9.0.1 from /home/spook/.local/lib/python3.5/site-packages (python 3.5)
๐ โ pyenv activate demo
pyenv-virtualenv: prompt changing will be removed from future release. configure `export PYENV_VIRTUALENV_DISABLE_PROMPT=1' to simulate the behavior.
(demo) ๐ โ python --version
Python 3.6.0
(demo) ๐ โ pip --version
pip 9.0.1 from /home/spook/.local/lib/python3.5/site-packages (python 3.5)
(demo) ๐ โ eval "$(pyenv init -)"
(demo) ๐ โ pip --version
pip 9.0.1 from /home/spook/.pyenv/versions/3.6.0/envs/demo/lib/python3.6/site-packages (python 3.6)
(demo) ๐ โ pyenv deactivate
๐ โ pip --version
pip 9.0.1 from /home/spook/.local/lib/python3.5/site-packages (python 3.5)
lmao.
pyenv update
Problematic behavior has disappeared. Will update if it does come back. Thanks to everyone who maintains this package.
Hmm. I still get this behavior.
It looks like you have pip installation at /home/spook/.local/lib/python3.5/site-packages and it has precedence than pip installation managed by pyenv/pyenv-virtualenv via shell's $PATH configuration. In general, this must be some shell configuration issue of your environment.
BTW, both pyenv-init and pyenv-virtualenv-init will try to put its command path at the top of $PATH. It means that the ordering of the execution matters to manage what to be invoked by given command. Running pyenv-init multiple times means that it forces shell to pick up pyenv's shims regardless of rest of shell configuration. I'd not recommend to do so unless you know what you're doing.
https://github.com/pyenv/pyenv/blob/v1.2.1/libexec/pyenv-init#L87-L96
https://github.com/pyenv/pyenv-virtualenv/blob/v1.1.1/bin/pyenv-virtualenv-init#L86-L99
I'm 99% sure I have my shell configured correctly and have no other commands that should affect the evaluation of my $PATH generally or those specific to pyenv/python.
That said, since updating like stated above, switching pyenv-virtualenvs results in the proper pip most of the time. I just double check now with pip --version to make sure.
Do you have any idea why I may sometimes not get a proper order evaluation order/execution of the shim on my $PATH? Could having multiple shells opened (with different pyenv-virtualenvs activated) possibly effect it? This isn't a real problem anymore but I would just like to understand more about the program! Thank you for maintaining such a great tool :smile:
Most helpful comment
It looks like you have pip installation at
/home/spook/.local/lib/python3.5/site-packagesand it has precedence than pip installation managed by pyenv/pyenv-virtualenv via shell's$PATHconfiguration. In general, this must be some shell configuration issue of your environment.BTW, both
pyenv-initandpyenv-virtualenv-initwill try to put its command path at the top of$PATH. It means that the ordering of the execution matters to manage what to be invoked by given command. Runningpyenv-initmultiple times means that it forces shell to pick up pyenv's shims regardless of rest of shell configuration. I'd not recommend to do so unless you know what you're doing.https://github.com/pyenv/pyenv/blob/v1.2.1/libexec/pyenv-init#L87-L96
https://github.com/pyenv/pyenv-virtualenv/blob/v1.1.1/bin/pyenv-virtualenv-init#L86-L99