Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to uninstall all python versions and use the default system version of OS X 10.10?

Tags:

python

macos

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!

like image 423
harisf Avatar asked Jun 15 '15 12:06

harisf


People also ask

How do I change Python to older version on Mac?

Open the terminal (bash or zsh) whatever shell you are using. Install python-3 using Homebrew (https://brew.sh). Look where it is installed. Change the default python symlink to the version you want to use from above.


1 Answers

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.

like image 78
rhashimoto Avatar answered Oct 06 '22 06:10

rhashimoto