Installing pyenv
$ brew install pyenv
$ echo -e '\nif command -v pyenv 1>/dev/null 2>&1; then\n eval "$(pyenv init -)"\nfi' >> ~/.bash_profile
$ source ~/.bash_profile
$ pyenv install 2.7.10
$ pyenv install 3.7.4
$ pyenv global 2.7.10
$ pyenv version
2.7.10 (set by ~/.pyenv/version)
- python and python2 point to 2.7.10
- python3 not found
$ python --version
Python 2.7.10
$ python2 --version
Python 2.7.10
$ python3 --version
pyenv: python3: command not found
The `python3' command exists in these Python versions:
3.7.4
- pip and pip2 point to 6.1.1
- pip3 not found
$ pip --version
pip 6.1.1 from ~/.pyenv/versions/2.7.10/lib/python2.7/site-packages (python 2.7)
$ pip2 --version
pip 6.1.1 from ~/.pyenv/versions/2.7.10/lib/python2.7/site-packages (python 2.7)
$ pip3 --version
pyenv: pip3: command not found
The `pip3' command exists in these Python versions:
3.7.4
$ pyenv global 3.7.4
$ pyenv version
3.7.4 (set by ~/.pyenv/version)
- python and python3 point to python 3.7.4
- python2 not found
$ python --version
Python 3.7.4
$ python2 --version
pyenv: python2: command not found
The `python2' command exists in these Python versions:
2.7.10
$ python3 --version
Python 3.7.4
- pip and pip3 point to 19.0.3
- pip2 not found
$ pip --version
pip 19.0.3 from ~/.pyenv/versions/3.7.4/lib/python3.7/site-packages/pip (python 3.7)
$ pip2 --version
pyenv: pip2: command not found
The `pip2' command exists in these Python versions:
2.7.10
$ pip3 --version
pip 19.0.3 from ~/.pyenv/versions/3.7.4/lib/python3.7/site-packages/pip (python 3.7)
You can also create virtualenvs with pyenv-virtualenv
$ brew install pyenv-virtualenv $ echo -e '\nif which pyenv-virtualenv-init > /dev/null; then\n eval "$(pyenv virtualenv-init -)"\nfi' >> ~/.bash_profile $ source ~/.bash_profile
$ pyenv global 2.7.10
$ pyenv virtualenv my2app
$ pyenv global 3.7.4
$ pyenv virtualenv my3app
python2 app
$ pyenv activate my2app
$ python --version
Python 2.7.10
or python3
$ pyenv activate my3app
$ python --version
Python 3.7.4
Installing PyTorch