pip3 need honor sys.executable in OS X · Issue #2031 · pypa/pip (original) (raw)
I found that pip3 from homebrew handles the shebang of installed scripts in wrong way(Homebrew/legacy-homebrew#32254). After further digging, I'm pretty sure it's pip's issue rather than homebrew.
The related code is in here:
def get_executable(): if sys.platform == 'darwin' and ('PYVENV_LAUNCHER' in os.environ): result = os.environ['PYVENV_LAUNCHER'] else: result = sys.executable return result
I don't know why you guys would overwrite sys.executable
. But as the test showed, under OS X python3 __PYVENV_LAUNCHER__
will always exist.
$ python
Python 2.7.8 (default, Aug 24 2014, 21:26:19)
[GCC 4.2.1 Compatible Apple LLVM 5.1 (clang-503.0.40)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import os;os.environ['__PYVENV_LAUNCHER__']
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/Cellar/python/2.7.8_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/UserDict.py", line 23, in __getitem__
raise KeyError(key)
KeyError: '__PYVENV_LAUNCHER__'
$ python3
Python 3.4.1 (default, Aug 24 2014, 21:32:40)
[GCC 4.2.1 Compatible Apple LLVM 5.1 (clang-503.0.40)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import os;os.environ['__PYVENV_LAUNCHER__']
'/usr/local/bin/python3'