Issue
I am trying to introduce separate versions of Python on MBP (10.13.15) and I am officially lost in the sauce.
I have succuessfully created both a pyenv for Python 3.7.4 and a virtualenv in the same.
However, I am running into issues where installs within the specific Python version using pyenv and virtualenv definitely do not appear to be isolated from my system and other paths. I have tried to exemplify this with some commands I am getting back from the terminal below.
For example, I am trying to install awsclieb (AWS command line for elastic beanstalk). But corresponding problems make me thing something else is going wrong with my PATH that will continue to bite me with other installs.
I have a pyenv/virtualenv:
(my-virtualenv-3.7.4) Peters-MacBook-Pro-4:~ peter$ python --version
returns: Python 3.7.4
pyenv shimed:
(my-virtualenv-3.7.4) Peters-MacBook-Pro-4:~ peter$ which python
returns: /Users/peter/.pyenv/shims/python
But now the problem
pip install awsebcli
will return important warnings:
The script chardetect is installed in '/Users/peter/.local/bin' which is not on PATH.
So I am thinking, okay install is not isolated within my pyenv and when I check:
eb --version
The return is the version installed in my default system (2.7.1), not my pyenv (3.7.4):
EB CLI 3.14.6 (Python 2.7.1)
My workaround was to specify the pyenv/virtualenv location of pip:
/Users/peter/.pyenv/versions/3.7.4/envs/my-virtualenv-3.7.4/bin/pip install awsebcli
This install does NOT have the PATH warnings which make me think the explicit path corrects the non-isolation problem.
However,
eb --version
still returns, my system install of:
EB CLI 3.14.6 (Python 2.7.1)
But, if I make path explicit:
(my-virtualenv-3.7.4) Peters-MacBook-Pro-4:~ peter$ /Users/peter/.pyenv/versions/3.7.4/envs/my-virtualenv-3.7.4/bin/eb --version
I get my new install returned:
EB CLI 3.15.3 (Python 3.7.4)
Where I am really lost is it appears my non-explicit versions of pip point within my virtualenv
(my-virtualenv-3.7.4) Peters-MacBook-Pro-4:~ peter$ pip --version
returns:
pip 19.0.3 from /Users/peter/.pyenv/versions/3.7.4/envs/my-virtualenv-3.7.4/lib/python3.7/site-packages/pip (python 3.7)
(my-virtualenv-3.7.4) Peters-MacBook-Pro-4:~ peter$ which pip
returns:
/Users/peter/.pyenv/shims/pip
Why is pip seemingly isolated in pyenv (via --version and which commands) but then pip installs in my system environment?
Solution
It seems for whatever reason, your pip is not being shimmed properly. You could try calling it as a module. Eg.:
python -m pip install awsebcli
You can even pass the virtualens you want to use with PYENV_VERSION:
PYENV_VERSION=my-virtualenv-3.7.4 eb --version
Answered By - Kapitol