PythonPath and Python Config Scripts
Question: I need some major help and am a bit scared since I do not want to mess up my
computer!I am on a Macbook Air running OSX 10.10.5. So I was following a
tutorial to help me learn Django. The tutorial isn't important. What is
important is that when doing it I changed my $PYTHONPATH to this:

export
PYTHONPATH=$PYTHONPATH:/usr/local/bin/../../../Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-
packages

Then I got scared with a homebrew warning here it is:

Warning: "config" scripts exist outside your system or Homebrew directories.
`./configure` scripts often look for *-config scripts to determine if software
packages are installed, and what additional flags to use when compiling and
linking.

Having additional scripts in your path can confuse software installed via
Homebrew if the config script overrides a system or Homebrew provided script
of the same name. We found the following "config" scripts:
/Library/Frameworks/Python.framework/Versions/2.7/bin/python-config
/Library/Frameworks/Python.framework/Versions/2.7/bin/python2-config
/Library/Frameworks/Python.framework/Versions/2.7/bin/python2.7-config

Warning: Your XQuartz (2.7.7) is outdated Please install XQuartz 2.7.8:
<https://xquartz.macosforge.org>

Warning: Python is installed at /Library/Frameworks/Python.framework

Homebrew only supports building against the System-provided Python or a brewed
Python. In particular, Pythons installed to /Library can interfere with other
software installs.

I got scared that I had messed something up because of two things first the
message relating to config scripts and then this one :

Warning: Python is installed at /Library/Frameworks/Python.framework

Homebrew only supports building against the System-provided Python or a brewed
Python. In particular, Pythons installed to /Library can interfere with other
software installs.

I did my research and here are the links I found:

[Repairing mysterious Python config scripts outside of the
system](http://stackoverflow.com/questions/17030490/repairing-mysterious-
python-config-scripts-outside-of-the-system)

[Homebrew Warnings additional "config" scripts in
python](http://stackoverflow.com/questions/34030890/homebrew-warnings-
additional-config-scripts-in-python)

The first one says to clean my path but I have no idea how to do that and the
second has no answers.

Any help would be greatly appreciated since I don't want to use my computer
until I can make sure everything is fixed!

EDIT: Will using export $PATH = /usr/local/bin fix my issue? I got that from
this link: <http://apple.stackexchange.com/questions/96308/python-
installation-messed-up>


Answer: As per my second comment: your PATH and PYTHONPATH depend on what you are
using. You wouldn't have to need PYTHONPATH if you install the necessary
packages for the particular Python you're using (using, for example, the
complementary pip); and you can amend PATH to include that Python executable,
if it's not already on PATH.

For example, I use Homebrew Python. My default PATH already includes
`/usr/local/bin`, and I use `/usr/local/bin/pip` to install packages for that
particular Python. No need for PYTHONPATH, everything works if I make sure I
use `/usr/local/bin/python`.

The catch with this is that `/usr/bin/python` is likely to be found earlier on
your PATH than `/usr/local/bin/python`. That will cause problems. Either use
the full path, `/usr/local/bin/python`, or set an alias (which is shorter to
type).

In fact, this way I'm running Python 2.7, 3.4 and 3.5 all in `/usr/local/bin`,
all with aliases. And I still have my system Python at `/usr/bin/python` for
system scripts. (The tricky part with multiple versions is pip: I've made
multiple copies of pip, each named differently, each with a different hash-
bang as the first line. Alternatively, I could run `/usr/local/bin/pythonx.y
/usr/local/bin/pip` and the correct `pip` is used.)

* * *

In short:

  * unset PYTHONPATH
  * make sure `/usr/local/bin` is included in PATH, but don't necessary set it at the front of PATH
  * remove Homebrew Python

The following depends on if you want to use Homebrew:

  * if you want to use the latest Python version(s), (re)install Python 2 (and 3; just try it out) with Homebrew.
  * Make aliases, if necessary, for `/usr/local/bin/python2.7` and corresponding `pip`. (Ditto Python 3.)
  * Install all packages that pip. Or, if you using `setup.py`, with the appropriate Python executable.

Something similar goes if you like to use, e.g., Anaconda Python.

If you attempt to install some binary package (e.g., through an installer),
you're bound to mess up things. Don't do it, use the appropriate pip.

