Issue
I'm facing an issue with getting the right 'pip' in my pyenv environment. I've tried reinstalling pyenv, but the issue persists. I'm on a MacBook Air, with the M1 chip. I'm essentially trying to keep pip and site-packages separate for my Python 3.9.4 install, but somehow it keeps referencing the 'pip' that is system-wide.
Current versions:
<me>:~:$ pyenv versions
* system (set by /Users/<me>/.pyenv/version)
3.9.4
At my $HOME prompt:
<me>:~:$ python -V
Python 2.7.16
<me>:~:$ which pip
/opt/homebrew/bin/pip
<me>:~:$ pip -V
pip 21.1 from /opt/homebrew/lib/python3.9/site-packages/pip (python 3.9)
Within <project 1>, I have a .python_version file which is for 3.9.4
<me>:~:$ cd ~//<project 1>/
<me>:~//<project 1>:$ python -V
Python 3.9.4
<me>:~//<project 1>:$ pyenv versions
system
* 3.9.4 (set by /Users/<me>/<project 1>/.python-version)
However, when I do a "which pip" or a "pip -V" it shows the system pip binary:
<me>:~/<project 1>:$ which pip
/opt/homebrew/bin/pip
<me>:~//<project 1>:$ pip -V
pip 21.1 from /opt/homebrew/lib/python3.9/site-packages/pip (python 3.9)
Any thoughts on how to get this working with the 'pip' under the pyenv version?
Solution
So, the root of the issue was that in the shims folder, no pip files were being installed.
When I replayed the install process a few times, I noticed that in the final install steps, I was seeing the following logged output:
Requirement already up-to-date: pip in $HOME/.local/lib/python3.9/site-packages (21.1)
I ended up deleting all existing pip installs on my machine (both in opt/homebrew/ and in $HOME/.local/lib/python*). When I tried reinstalling, I then got the following:
* WARNING: The scripts pip3 and pip3.9 are installed in '/$HOME/.pyenv/versions/3.9.4/bin' which is not on PATH.
* Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
* Successfully installed pip-20.2.3 setuptools-49.2.1
As suggested above, added the following snippet to my bash_profile file:
export PATH="$HOME/.pyenv/versions/:$PATH"
This could probably be avoided if the pyenv installer just ignored existing installs and went ahead with ensuring pip is installed in the shims folder.
Answered By - thomassantosh Answer Checked By - Terry (WPSolving Volunteer)