Skip to content

Instantly share code, notes, and snippets.

@sts10
Last active September 9, 2020 13:53
Show Gist options
  • Select an option

  • Save sts10/8f95102e88c4ab03089563076130c672 to your computer and use it in GitHub Desktop.

Select an option

Save sts10/8f95102e88c4ab03089563076130c672 to your computer and use it in GitHub Desktop.
Installing and setting up a decent Python configuration in MacOS

Installing and setting up a decent Python configuration in MacOS 10.11

Before I took these steps, I ran brew uninstall python in an attempt to clear out a different Python installation. I also had to clear out some stuff in my .bash_profile.

  1. Install Pyenv via Homebrew: brew update && brew install pyenv
  2. Add necessary stuff to ~/.bash_profile: echo -e 'if command -v pyenv 1>/dev/null 2>&1; then\n eval "$(pyenv init -)"\nfi' >> ~/.bash_profile
  3. Restart terminal.
  4. Maybe install dependencies? (Thouhg you may be good to go already.)
  5. pyenv install --list and pick new-ish-but-stable versions of python2 and python3 to install. For example: pyenv install 3.7.0 2.7.15
  6. You can set version 3 as the global, with 2 as fall-back: pyenv global 3.7.0 2.7.15. You can also set your system's Python as a secondary fallback by running pyenv global 3.7.0 2.7.15 system.
  7. Check that pip is installed (I think it's included?). You should be able to upgrade pip3 with pip3 install --upgrade pip and pip2 with pip2 install --upgrade pip

Let's see how we did: If successful, python2 gets you Python 2, python3 or python gets you Python 3. You should get similar results with pip2/pip3/pip. To install a package, you'd run pip install <package-name>.

Deoplete / Neovim

If you use Neovim + Deoplete, you probably want to run pip3 install neovim to ensure Deoplete works smoothly (see Deoplete's requirements). I also ran pip2 install neovim because :CheckHealth told me to. For Deoplete to work, you may need to run :UpdateRemotePlugins in Neovim. Neovim's :CheckHealth is your friend here.

2020 updates / notes

These two blog posts may offer better, newer solutions:

Specifically, if you only need Python so that you can install packages via pip (as opposed to active development using Python), I'm hoping that pipx may be a better, more self-contained solution. Users may even be able to bypass installing a python executable themselves?

For example, on MacOS, I'm hoping I can just do this in order to install the "neovim" package?:

brew install pipx
pipx ensurepath
pipx install neovim
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment