Managing system python2.7, brew python2.7, and brew python3 on the same machine

时间:2018-02-01 18:41:33

标签: python homebrew

My system python2.7 (/usr/bin/python) does not have usr/local/lib/python2.7/site-packages in its sys.path. As a result, various installed scripts that explicitly reference it fail (with, e.g., "ImportError: No module named appdirs").

For the most part, it's no problem, since I mostly use brew python 2.7 (at /usr/local/opt/python/libexec/bin/python), which does point at it.

If I add that 2.7 site-packages to $PYTHONPATH, then python3 picks it up and complains ("This package should not be accessible on Python 3").

If I don't, then the aforementioned scripts fail. Solutions include:

  • Using pyenv / virtualenv. This is a bit inconvenient.
  • Setting PYTHONPATH only while invoking those scripts. Unfortunately, some scripts explicitly unset PYTHONPATH.

Are there any obvious solutions I'm missing?

0 个答案:

没有答案