I want my system to use /usr/bin/python, but it’s currently using /opt/local/bin/python, which points to /usr/bin/python2.6. I tried modifying the PATH variable in my .bashrc as
…and then set a symbolic link in ~/bin to point to /usr/bin/python. i.e.
~/bin/python --> /usr/bin/python
I figured this might prioritize this symlink over the /opt/local version if it came before the other one in the PATH variable, but when I opened a new shell I still found python pointing to /opt/local/bin. Any advice on a good way to get the system to use /usr/bin/python?
Also, I usually use ipython as opposed to python directly. I’m assuming that if the system starts to use the correct version of python then ipython would also use that version? If not, how could I also get ipython to use the correct version?
I can’t tell exactly what’s going on with ~/.bashrc, but here’s my stab in the dark. If you’re using Terminal.app and you haven’t changed your preferences, Terminal will by default invoke Bash as an interactive login shell, which doesn’t execute commands from ~/.bashrc. As noted, adding
if [ -f ~/.bashrc ]; then . ~/.bashrc; fi
to the end of ~/.bash_profile will explicitly tell Bash to execute commands found in ~/.bashrc, if it exists.
Once your system is using the right version of Python, then use that version to install IPython again (using the same options as the original install, I think). Then IPython should be available in the Python version you wanted to use.
IPython’s FAQ also covers how to use IPython with two versions of Python simultaneously, if you’re interested.