# sudo apt-get install git python-pip make build-essential libssl-dev zlib1g-dev libbz2-dev libreadline-dev libsqlite3-dev
# pip install virtualenv virtualenv-clone virtualenvwrapper
# git clone https://github.com/yyuu/pyenv.git /opt/pyenv
# git clone https://github.com/yyuu/pyenv-virtualenvwrapper.git /opt/pyenv/plugins/py-virtualenvwrapper
# cat << 'EOF' >> /etc/bash.bashrc
# pyenv global
if [ -d /opt/pyenv ]; then
export PYENV_ROOT="/opt/pyenv"
export PATH="$PYENV_ROOT/bin:$PATH"
eval "$(pyenv init -)"
pyenv virtualenvwrapper
fi
# exec "$SHELL"
# pyenv install 3.5.1
# pyenv install 2.7.1
EOF
$ mkdir ~/test/ && cd ~/test/
$ venv fs-venv-2 -p $(pyenv prefix 2.7.11)/bin/python
$ venv fs-venv-3 -p $(pyenv 3.5.1)/bin/python
$ ls
fs-venv-2 fs-venv-3
$ python --version
Python 2.7.6
$ source fs-venv-2/bin/activate
(fs-venv-2) $ python --version
Python 2.7.11
(fs-venv-2) $ deactivate
$ source fs-venv-3/bin/activate
(fs-venv-3) $ python --version
Python 3.5.1
(fs-venv-3) $ deactivate
$
$ mkvirtualenv vew-2 -p $(pyenv prefix 2.7.11)/bin/python
(vew-2) $ python --version
Python 2.7.11
(vew-2) $ deactivate
$ mkvirtualenv vew-3 -p $(pyenv prefix 3.5.1)/bin/python
(vew-3) $ python --version
Python 3.5.11
(vew-3) $ deactivate
$
As a regular user, if you pyenv shell 2.7.11
or pyenv shell 3.5.1
and then try to pip install
into the global space, it will give a permission denied
error which I think is a good thing! Forces
regular users to use a venv of some kind.