When searching for a solution for my problem, all advice points towards just prepending my $PATH
variable with the path to that version of Python, but that doesn't help.
Here's my .bash_profile:
PATH="/usr/local/mysql/bin:/bin:/usr/bin:/usr/local/bin:~/bin"
export PATH="~/bin/python/anaconda:/opt/local/bin:/opt/local/sbin:$PATH"
export PATH="/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4:$PATH"
PYTHONPATH="/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4:${PYTHONPATH}
$ which python
/usr/bin/python
>>> import sys
>>> for p in sys.path:
... print(p)
...
/Library/Frameworks/Python.framework/Versions/3.4/lib/python34.zip
/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4
/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/plat-darwin
/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/lib-dynload
/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages
The author of the suggestion that solved my problem deleted their post already, but the command
sudo ln -s /usr/bin/python /Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4
did the trick.Almost all *nix systems like MacOSX, most Linux distributions, expect
python
to refer to Python 2;python3
to Python 3. If you change this, something might break badly. Thus even though the PEP 394 talks about the "default" python distribution forpython
, and that all Python 2 scripts would usepython2
in shebang, it is not the fact yet. Many programs expectpython
to stand forpython2
.Furthermore even in such a system you still should prefix your scripts with
python3
and explicitly run your Python 3 programs with that command. Just prefix your scripts with something likeand it should work.
If you are bugged about python 2.7 opening whenever you execute
python
, do an alias in your.bashrc
:Also I am not sure if whatever you are doing with
PYTHON_PATH
is wise; the python interpreter will know where to look for its own libraries without this hackery.