Skip to content

Instantly share code, notes, and snippets.

@theothermattm
Last active October 8, 2019 12:39
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 theothermattm/59db9cd2737aac7560b962b5c918f61c to your computer and use it in GitHub Desktop.
Save theothermattm/59db9cd2737aac7560b962b5c918f61c to your computer and use it in GitHub Desktop.
Installing Python so it doesn't suck on MacOS

Thanks to @kevlarr for this info... Saving it myself for reference.

The easiest way to get started is via pyenv and virtualenv.

  • Install pyenv via brew install pyenv
  • Add eval "$(pyenv init -)" to your bash, etc. profile if you want to enable autocomplete (hint: you do),
  • Install project Python version via pyenv install 3.6.81

1 If you are running Mojave and are having issues building (looking at you, zlib), you likely need to install C header files since Mojave actually cleared a number away that were present in previous editions

Once this is complete, it's time to install virtualenv and get it hooked up to pyenv via pyenv-virtualenv.

  • Install via brew install pyenv-virtualenv
  • Like pyenv, add eval "$(pyenv virtualenv-init -)" to your terminal profile to enable autocomplete

note, if you want a handy block of code to only run this in your bash profile if pyenv is installed you can use:

 # if pyenv is installed, initialize it
if hash pyenv 2>/dev/null; then
    eval "$(pyenv init -)"
    eval "$(pyenv virtualenv-init -)"
fi

after you do all of the above (replacing pyenv install 3.6.8 with whatever version you want), you would do…

$ pyenv virtualenv 3.6.8 my-new-env
$ pyenv activate my-new-env
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment