Skip to content

Instantly share code, notes, and snippets.

@tcostam
Last active June 15, 2018 02:59
Show Gist options
  • Save tcostam/7ef0526a5f662044a6ed1d7f3f747896 to your computer and use it in GitHub Desktop.
Save tcostam/7ef0526a5f662044a6ed1d7f3f747896 to your computer and use it in GitHub Desktop.
How to setup Python 3 correctly on Mac OSX

Python Setup

How to setup Python 3 correctly on Mac OSX

Install Python

brew install python3

Add PATH to ~/.bash_profile and ~/.zshrc

export PATH=/usr/local/share/python:$PATH

Troubleshooting

pip permission errors

If you see a permission error probably it is due to the fact that your site-packages directory (where pip is trying to install to) is protected and owned by an administrator.

You should not install any packages to the system version of Python and of course (almost) never use sudo forced installs for security reasons.

See

  1. https://www.bleepingcomputer.com/news/security/ten-malicious-libraries-found-on-pypi-python-package-index/; and
  2. https://stackoverflow.com/questions/46675670/permission-error-with-pip-python-3

Make sure you install Python using Homebrew, Python.org, or Canopy, which will leave the system Python alone. Example: python is the system python, python2 is Python version 2, and python3 is Python version 3. This also makes it more clear which version you are using. Also do not have a pip command - not on path - so you can't accidentally install something to system Python. Explicitly call pip2 or pip3. Using Homebrew Python will do all of this for you, so it's the most-favored recommendation of the many Python distributions available.

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