monty
monty

Reputation: 33

Eliminating duplicate python versions installed on computer- Mac OS

I'm currently dealing with an issue that was probably caused when I first started programming and is now catching up with me. Before I knew much about programming, virtualenvs, pip, etc... I must have installed python in multiple locations on my computer from different sources. My Mac actually came with python installed (I didn't know beforehand). Typing a which command gives me these locations

$ which -a python
/opt/local/bin/python
/opt/local/bin/python
/Library/Frameworks/Python.framework/Versions/2.6/bin/python
/usr/bin/python
/usr/local/bin/python

Additionally

$type python
python is hashed (/opt/local/bin/python)

To emphasize the confusion that this is giving me, typing the "python" command in terminal opens up Python 2.7.5. This is fine, since I prefer using this version as my default. Installing something with pip however, (for example virtualenv) is placed in this location

virtualenv in /Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6
/site-packages/virtualenv-1.11.6-py2.6.egg

Currently I'm trying to figure out a solution to this problem, deciding on whether to reformat my macbook, or manually and meticulously try to fix the problem. Anyone have any advice?

Upvotes: 3

Views: 2033

Answers (1)

simesy
simesy

Reputation: 470

I had a similar issue with which -a ruby and brew unlink ruby && brew link ruby didn't fix it. Even weirder is the version of ruby changed depending on whether I run ruby --version or /usr/local/bin/ruby --version.

I noticed my $PATH had duplicate /usr/local/bin references. I removed the one coming from /etc/paths and this reduced the duplicates, and ruby --version returns the expected version. I then changed it back and instead changed the (what I now realise is) superfluous /usr/local/bin in my .bash_profile. Again the correct version. I returned the whole thing to what it was before - again the correct version.

So in summary, try removing/re-adding any reference to the duplicate path and maybe OSX will right itself!

Upvotes: 1

Related Questions