Skip to content

Instantly share code, notes, and snippets.

@jamiefrench
Last active April 11, 2023 15:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jamiefrench/bea2c0bee219b96c30f0e958ca236bdf to your computer and use it in GitHub Desktop.
Save jamiefrench/bea2c0bee219b96c30f0e958ca236bdf to your computer and use it in GitHub Desktop.
Python Environments With Pyenv And Virtualenv

brew upgrade

brew install pyenv

brew install pyenv-virtualenv

Add the following lines to ~/.zprofile and ~/.zshrc (or ~/.bash_profile and ~/.bashrc if you’re still using bash):

~/.zprofile

eval "$(pyenv init --path)"

~/.zshrc

if command -v pyenv 1>/dev/null 2>&1; then
    eval "$(pyenv init -)"
fi

virtual environments that are currently available

pyenv versions

list python versions available

pyenv install -l

install specific python version

pyenv install 3.10.2

list python versions installed

pyenv versions

create new virtual environment

pyenv virtualenv 3.10.2 venv_3_10_2

list virtual environements

pyenv virtualenvs

activate virtual environment

pyenv activate venv_3_10_2

install requirements

pyenv exec python -m pip install pyspark

deactivate virtual environment

pyenv deactivate venv_3_10_2

delete virtual environment

pyenv virtualenv-delete venv_3_10_2

Acknowledgements

https://fathomtech.io/blog/python-environments-with-pyenv-and-vitualenv/ https://towardsdatascience.com/how-to-use-manage-multiple-python-versions-on-an-apple-silicon-m1-mac-d69ee6ed0250

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