I decided to do fresh install of El Capitan over the weekend so as to upgrade from Yosemite. While El Capitan does come with Python 2.7 preinstalled, it does not include pip. If you search Ye Mighty Internet on how to remedy this situation, you’re likely to find suggestions on using sudo or Homebrew. I’m not a fan of either method.
In the case of using sudo, avoiding that is typically recommended whenever practical, and with El Capitan there’s this new thing called System Integrity Protection that may prevent it entirely. You’ll need to install pip without using sudo unless you’re going to go mucking about with things that have been put into place to prevent you from doing just that.
In the case of Homebrew, I’m just going to go ahead and get this out into the open. I don’t like it. I think it was useful for a time that has long since past, and problematic even then. If you like it, great! However, my sense of it is that if you need Homebrew then you are far better off using something like Vagrant.
Installing pip Without Homebrew or sudo
Installing pip on OS X is actually extremely easy. You don’t need sudo, and you don’t need something like Homebrew.
You’ve just completed a user install of pip! Now you’ll need to tell your shell where to find it. In order to do that, you’ll need to add a line to your .bash_profile ($HOME/.bash_profile). Open this file in your favorite editor, creating it if it does not already exist, and ensure there is a line that resembles the following:
That will allow your shell to find pip as well as other scripts that may get installed by other packages that you install using pip.
To load these changes in your current terminal session, issue . . .
Future/New terminal sessions will work as if by magic.
The only other thing you need to do is to remember to use the ‘–user’ argument for any relevant pip command. e.g. . . .
This doesn’t apply if you’re in a Python virtual environment, which you typically should be, in which case your pip command will automatically install packages in the proper location.
It should be noted that according to a footnote on the pip installation page, the pip developers are considering making the –user argument the default behavior. In addition, this method may not be fully tested.
The pip developers are considering making –user the default for all installs, including get-pip.py installs of pip, but at this time, –user installs for pip itself, should not be considered to be fully tested or endorsed.
With that being said, and this is really the most important part, you should generally be operating in a Python virtual environment anyway. A user install of pip is perfectly fine to allow you to easily get set up with the tools needed to do that as well as a variety of other packages that get installed via pip (virtualenv, ansible, awdcli, s3cmd, etc.).