Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.