0

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

https://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: https://apple.stackexchange.com/questions/96308/python-installation-messed-up

Community
  • 1
  • 1
  • Where (and why) did you get the suggestion to change your PYTHONPATH to include `/usr/local/bin/../../../Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages`? Note also that this reduces to `/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages`, so the suggestion seems a bit flawed to me (no use in making a path relative if you go up 3 levels from the root directory, then go 3 levels down again). –  Dec 09 '15 at 01:16
  • The reason I'm asking is that, if you want to use your Homebrew Python, don't set a PYTHONPATH pointing elsewhere. If you want to use the system Python, don't bother with Homebrew. If you want to use Homebrew Python with system-installed libraries, then *don't*: re-install those libraries for Homebrew Python. –  Dec 09 '15 at 01:17
  • @Evert I think I am going to stop messing around with Python on my system since I have gotten other Python installation problems before. Can you tell my what I should point my $PATH and $PYTHONPATH to? If I need to clear it how do I do that? – CompletePythonNewbie Dec 09 '15 at 12:37

1 Answers1

0

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.

  • Ok I hope I understood what you think I should do. I am still pretty knew to this so I may need some extra guidance. First of all I have no idea how to unset the PYTHONPATH. I assume I should export it and make it equal nothing. I know how to access my path now but I don't know how to include the /usr/local/bin correctly. Help with those to things would be greatly appreciated @Evert! – CompletePythonNewbie Dec 29 '15 at 12:50
  • One more thing I used the installer from the python.org website before I posted my question so that may complicate the process. – CompletePythonNewbie Dec 29 '15 at 13:19
  • Your PYTHONPATH is, afaik, never set by default. So you probably should comment-out the line where it is set in one of your login dot-files. Otherwise, you can [use `unset`](http://stackoverflow.com/questions/6877727/how-do-i-delete-unset-an-exported-environment-variable). –  Dec 30 '15 at 15:39
  • I've never used the python.org installer, so I'm not sure what or how it install things. The danger is (as your case shows), that when something seems missing, one starts installing things through another package, and before you know it, you have an odd mix of Apple's Python installation, MacPython (old name) from python.org's installer, and Homebrew Python. Throw in Conda's Python and the mess is complete. I've found Homebrew working fine for me, other people may suggest Conda, since that installs C library dependencies as well. Just avoid mixing them. –  Dec 30 '15 at 15:42