A "distutils.cfg" has been written, specifying the install-scripts folder as:
/usr/local/share/python

If you install Python packages via "pip install x" or "python setup.py install"
(or the outdated easy_install), any provided scripts will go into the
install-scripts folder above, so you may want to add it to your PATH.

A "distutils.cfg" has been written, specifying the install-scripts folder as:
/usr/local/share/python

If you install Python packages via "pip install x" or "python setup.py install"
(or the outdated easy_install), any provided scripts will go into the
install-scripts folder above, so you may want to add it to your PATH.

I'd like to find the reason, so I can put a check in homebrew (perhaps for the doctor) so that he will outright print a message that helps others.

A little background.

We see that somehow, when installing, the pip tries to load something from /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources.py which it should really not.
How can this come, since we have checked that the /usr/local/bin/python does not have that dir in its sys.path?

I assumed some file called easy_install.pth or setuptools.pth to be the "evil" here.
Because these files contain (on my test system: the path to the /System/Libr... etc.

Do you have got a file named .pydistutils.cfg in your home? Check with ls -la ~/.pydistutils.cfg.
Have you set the env var PYTHONHOME or PYTHONPATH (or anything beginning with PYTHON) ?

@samueljohn It seems like I have the exact same issue and I've tried reinstalling python with brew, and I just tried adding $(brew --prefix)/share/python which becomes '''/usr/local/share/python/" to my PATH (.bash_profile) without any luck. Any tips on what I could try?

@anton164 please open a new issue.
Also note that brewed python no longer puts executable python scripts into share/python but directly into $(brew --prefix)/bin. The brew doctor knows already about this.