Skip to content

Instantly share code, notes, and snippets.

@jcushman
Created May 12, 2019 22:23
Show Gist options
  • Save jcushman/cd8a3ee75e27bbe64369c96249720330 to your computer and use it in GitHub Desktop.
Save jcushman/cd8a3ee75e27bbe64369c96249720330 to your computer and use it in GitHub Desktop.
pyenv setup notes
### install pyenv for Mac with bash ###
# install pyenv
brew install pyenv
# install pyenv-virtualenv
git clone https://github.com/pyenv/pyenv-virtualenv.git $(pyenv root)/plugins/pyenv-virtualenv
# configure pyenv
echo -e 'if command -v pyenv 1>/dev/null 2>&1; then\n eval "$(pyenv init -)"\nfi' >> ~/.bash_profile
# configure pyenv-virtualenv
echo 'eval "$(pyenv virtualenv-init -)"' >> ~/.bash_profile
### set up pyenv for a project ###
# install target python (if not installed)
pyenv install 3.4.2
# create venv
pyenv virtualenv 3.4.2 myenv
# run in project root:
# activate venv, and write .python-version
pyenv local myenv
# (from now on changing to project dir should activate myenv)
### other useful stuff ###
# ignore .python-version file if it shouldn't be in version control
echo ".python-version" >> .git/info/exclude
# get path to python, if you need it for the PyCharm project interpreter for example
pyenv which python
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment