Eliminate duplicate python versions installed on a computer - Mac OS
I am currently tackling an issue that was probably caused when I first started programming and am now catching up with me. Before I knew a lot about programming, virtualenvs, pip, etc. I had to install python in multiple locations on my computer from different sources. My Mac actually came with python installed (I didn't know beforehand). Entering the command that 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 this gives me, typing "python" in a terminal opens Python 2.7.5. This is fine as I prefer to use this version as my default. However, installing something with pip (like virtualenv) is hosted at this location
virtualenv in /Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6
/site-packages/virtualenv-1.11.6-py2.6.egg
I am currently trying to find a solution to this problem by deciding whether to reformat my macbook, or manually and carefully try to fix the problem. Anyone have any advice?
source to share
I had a similar problem with which -a ruby
and brew unlink ruby && brew link ruby
not fixed. An even weirder version of the ruby ββversion changes depending on whether I run ruby --version
or /usr/local/bin/ruby --version
.
I noticed that my $ PATH had duplicate / usr / local / bin links. I removed the one that came from /etc/paths
and this reduced the duplicates while ruby --version
returning the expected version. Then I changed it and instead changed (which I now understand) the extra / usr / local / bin in my .bash_profile
. Again, the correct version. I brought back everything before - correct version again.
So try removing / re-adding any link to the duplicate path, and maybe OSX will do the trick!
source to share