TL;DR: Is this $PATH string backwards if I'm trying to source python 2.7 from the homebrew-installed version?
$ echo $PATH
/Library/Frameworks/Python.framework/Versions/3.4/bin:/Library/Frameworks/Python.framework/Versions/2.7/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/opt/X11/bin:/usr/local/git/bin
I had used brew install python
to put python 2.7.13 on El Capitan (OS X 10.11), and things were working fine for a while. Then I tried to deploy a venv, which went sideways, and I think my troubleshooting uncovered a deeper issue (or several). My goal is to have Python 2.7.x installed and functioning aside from OS X's python installation. I'm also aiming for pip
and venv
, in addition to some other imported modules to be installed with the brew-installed python 2.7 as well. (I understand messing with the system-original Python can cause deep, deep issues - so I'd like to leave it completely untouched.)
$ brew info python
python: stable 3.6.5 (bottled), devel 3.7.0b3, HEAD [pinned at 2.7.13]
Interpreted, interactive, object-oriented programming language
https://www.python.org/
/usr/local/Cellar/python/2.7.13 (6,337 files, 87.0MB) *
Built from source on 2017-02-01 at 19:23:01
From: https://github.com/Homebrew/homebrew-core/blob/master/Formula/python.rb
brew info python
shows me that python 2.7.13 is installed and pinned. Great. However, if that's the case, why does which python
point to the system-installed version?
$ which python
/Library/Frameworks/Python.framework/Versions/2.7/bin/python
Checking $PATH, it looks like something went wrong there ...
$ echo $PATH
/Library/Frameworks/Python.framework/Versions/3.4/bin:/Library/Frameworks/Python.framework/Versions/2.7/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/opt/X11/bin:/usr/local/git/bin
So my current $PATH is (<cr>
after :
for clarity):
- /Library/Frameworks/Python.framework/Versions/3.4/bin:
- /Library/Frameworks/Python.framework/Versions/2.7/bin:
- /usr/bin:
- /bin:
- /usr/sbin:
- /sbin:
- /usr/local/bin:
- /opt/X11/bin:
- /usr/local/git/bin
Should the proper $PATH order be
- /usr/local/bin:
- /Library/Frameworks/Python.framework/Versions/3.4/bin:
- /Library/Frameworks/Python.framework/Versions/2.7/bin:
- /usr/bin:
- /bin:
- /usr/sbin:
- /sbin:
- /opt/X11/bin:
- /usr/local/git/bin
According to this page, I need to add export PATH="/usr/local/bin:/usr/local/sbin:$PATH"
to my .profile
, which gives me three questions:
1. Do I need to add /usr/local/sbin
to my $PATH?
2. I thought my $PATH would persist through reboots - am I wrong?
3. If I need to add it to ~/.profile
, can I add it to ~/.bash_profile
instead?
Finally, here's one of the errors I'm seeing now:
$ vim peuler.py
Traceback (most recent call last):
File "<string>", line 9, in <module>
File "/Users/user/.vim/bundle/powerline/powerline/__init__.py", line 6, in <module>
import logging
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/logging/__init__.py", line 26, in <module>
import sys, os, time, cStringIO, traceback, warnings, weakref, collections
ImportError: No module named time
An error occurred while importing powerline module.
This could be caused by invalid sys.path setting,
or by an incompatible Python version (powerline requires
Python 2.6, 2.7 or 3.2 and later to work). Please consult
the troubleshooting section in the documentation for
possible solutions.
Unable to import powerline, is it installed?
Press ENTER or type command to continue
To me, this indicates something went very wrong with the system-installed version of Python - is that the case? (No module named time
? That can't be good..) Can I just rip out all of the homebrew-installed Python, ensure that the OS-installed version of Python is pure, and then re-install everything with homebrew?... or is the System-level Python totally jacked?