11

I'm looking for a way to cleanly uninstall all versions of python on OS X 10.10 except the default version that followed with the Mac. How do I proceed?

Currently I've some weird behaviour. When typing which -a python I get the following output:

/Users/harisfawad/anaconda/bin/python
/Library/Frameworks/Python.framework/Versions/2.7/bin/python
/usr/local/bin/python
/usr/bin/python

Why doesn't the default version of python in /System/Library/.../ show up here? I can locate that version in Finder, so I know that it isn't deleted.

Also, echo $PYTHONPATH returns an empty line.

Can I just go ahead and delete all these folders and expect the default version to run correctly?

I've read a similar inquiry here http://bugs.python.org/issue7107 but I'm not sure if this is still applicable to python versions 2.7/3.4.

This is also a similar question How to uninstall Python 2.7 on a Mac OS X 10.6.4? But again, I don't want to be careless and do the uninstalling before making sure that the system provided version works.

UPDATE: When running brew doctor I get this Warning: "config" scripts exist outside your system or Homebrew directories. And it goes on listing the "config" files in /.../anaconda/bin and in /Library/.../bin.

UPDATE2: I've successfully gone back to the default version of python that was included in OS X. All the above versions of python where moved to trash, except /usr/bin/python. Thanks, @rhashimoto and @PadraicCunningham!

Community
  • 1
  • 1
harisf
  • 149
  • 1
  • 1
  • 10

1 Answers1

6

The file /usr/bin/python (and /usr/bin/pythonw, which is a hard link to the same file) is actually a launcher program that invokes the default version of Python from /System/Library/Frameworks/Python.framework/Versions. You can select the version (2.6 and 2.7 in Yosemite) the launcher invokes using either the defaults command or the VERSIONER_PYTHON_VERSION environment variable.

If you want to run a specific version manually, you can invoke /usr/bin/python2.6 or /usr/bin/python2.7, which are symbolic links into /System/Library/Frameworks/Python.framework/Versions.

You should be fine removing all other Python implementations you list from your path, including /Library/Frameworks/Python.framework/Versions/2.7/bin/python (not sure how you got that one). It would still be wise to move them somewhere (e.g. your trash folder) to test your change before deleting them permanently.

rhashimoto
  • 15,650
  • 2
  • 52
  • 80
  • Alright, so I just moved the above versions of python to trash. Now `which -a python` returns only `/usr/bin/python`, which I guess is an indication of that everything has returned to default. Thanks for explaining that this is a symbolic link to the python version at `/System/...`. Typing `python` now launches the default version on darwin. But, `echo $PYTHONPATH` still returns a blank. Any idea as to what that means? – harisf Jun 15 '15 at 18:45
  • [`PYTHONPATH`](https://docs.python.org/2/using/cmdline.html#envvar-PYTHONPATH) augments the default module search path. You can set it to whatever you want (if you don't set it then it will be blank). If you want to see what the current path is, you can access [`sys.path`](http://stackoverflow.com/questions/5751292/how-to-get-current-import-paths-in-python). – rhashimoto Jun 15 '15 at 18:48
  • Note that I didn't say that `/usr/bin/python` is a symbolic link. It is a small launcher program that checks what the chosen default version is and then invokes that version. – rhashimoto Jun 15 '15 at 18:51
  • `sys.path` returns several different paths `/System/...` and one at `/Library/Python/2.7/site-packages`. So I'm pretty sure I'm back to the point of pre-installation different versions of python, both from python.org and using homebrew. Thanks, @rhashimoto! – harisf Jun 15 '15 at 19:12