Skip to content

Instantly share code, notes, and snippets.

@rca
Created Jan 27, 2020
Embed
What would you like to do?
Setting up Pyhon on a Mac

Installing Python3 on a Mac

Getting a sane Python3 runtime on a Mac can be tedious. The most painless way I have found thus far installing a Python3 package from python.org and, from there, installing two additional packages into the system directory: pip and pipx.

Install Python

Install Python with a package from python.org. This post uses 3.6.8: https://www.python.org/downloads/release/python-368/

At this point, close the current shell and launch a new shell. This will ensure you have Python 3.6 in your PATH; you should see something similar to:

$ which python3.6
/Library/Frameworks/Python.framework/Versions/3.6/bin/python3.6

Installing pip

pip is the easiest, modern way to install 3rd party Python packages on your system. It can be installed with the command:

easy_install-3.6 pip

Once installed you should see its location with the command:

$ which pip
/Library/Frameworks/Python.framework/Versions/3.6/bin/pip

Installing pipx

pipx creates isolated environments for python applications. That way, when 3rd party applications require different versions of a common package, the system doesn’t get polluted and unstable:

pip install pipx

Once pipx is installed, its bin/ directory can be added to the PATH with the command:

pipx ensurepath

These are the only packages installed at the system level. Now, everything else is installed with pipx

Like with the Python install above, close out of the current shell and launch a new one. When you run echo $PATH you should see ${HOME}/.local/bin in the path.

Installing 3rd party packages

There is one important package for development that should be installed: pipenv:

pipx install pipenv

Once that command is run, which pipenv should produce something similar to:

$ which pipenv
${HOME}/.local/bin/pipenv

From here, development on a project should be done with pipenv

More 3rd party things

Another useful 3rd party application is the AWS command line tools. With the install covered here, that can be installed with the command pipx install awscli, and it will show up like so:

$ which aws
/Users/berto/.local/bin/aws
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment