Skip to content

Instantly share code, notes, and snippets.

@stephenhandley
Last active June 30, 2020 08:09
Show Gist options
  • Save stephenhandley/828811cad9b089c6471a3b0bb3125c06 to your computer and use it in GitHub Desktop.
Save stephenhandley/828811cad9b089c6471a3b0bb3125c06 to your computer and use it in GitHub Desktop.
pyenv

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

Installing versions

$ pyenv install 2.7.10
$ pyenv install 3.7.4

Use Python2

$ 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

Use Python3

$ 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
@stephenhandley
Copy link
Author

stephenhandley commented Aug 9, 2019

Installing PyTorch

pyenv install Anaconda3-5.3.1
pyenv activate Anaconda3-5.3.1
conda create -n pytorch
conda activate pytorch
conda install pytorch torchvision -c pytorch

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment