I want to completely remove Python 2.7 from my Mac OS X 10.6.4. I managed to remove the entry from the PATH
variable by reverting my .bash_profile
. But I also want to remove all directories, files, symlinks, and entries that got installed by the Python 2.7 install package. I've got the install package from http://www.python.org/. What directories/files/configuration file entries do I need to remove? Is there a list somewhere?

- 15,395
- 32
- 113
- 196

- 19,645
- 24
- 81
- 137
17 Answers
Do not attempt to remove any Apple-supplied system Python which are in /System/Library
and /usr/bin
, as this may break your whole operating system.
NOTE: The steps listed below do not affect the Apple-supplied Python 2.7; they only remove a third-party Python framework, like those installed by python.org installers.
The complete list is documented here. Basically, all you need to do is the following:
Remove the third-party Python 2.7 framework
sudo rm -rf /Library/Frameworks/Python.framework/Versions/2.7
Remove the Python 2.7 applications directory
sudo rm -rf "/Applications/Python 2.7"
Remove the symbolic links, in
/usr/local/bin
, that point to this Python version. See them usingls -l /usr/local/bin | grep '../Library/Frameworks/Python.framework/Versions/2.7'
and then run the following command to remove all the links:
cd /usr/local/bin/
ls -l /usr/local/bin | grep '../Library/Frameworks/Python.framework/Versions/2.7' | awk '{print $9}' | tr -d @ | xargs rm
- If necessary, edit your shell profile file(s) to remove adding
/Library/Frameworks/Python.framework/Versions/2.7
to yourPATH
environment file. Depending on which shell you use, any of the following files may have been modified:~/.bash_login
,~/.bash_profile
,~/.cshrc
,~/.profile
,~/.tcshrc
,~/.zshrc
, and/or~/.zprofile
.
-
214Thanks for the heads up Ned, I did remove it, and found out the hard way that you have to reinstall Mac OS X. I'm leaving this here for anyone else who comes along and thinks the same thing I did. Don't remove Python in /System/Library/Frameworks/... None of your apps will work and you'll have to reinstall OS X. – brthornbury Oct 06 '14 at 17:42
-
55Python 2.7 is the default system Python on recent systems, while on 10.6.4 it was 2.6 and 2.7 was user-installed. DO NOT UNINSTALL 2.7 FROM A RECENT OS X SYSTEM. – Martijn Pieters May 31 '16 at 15:08
-
46The steps above do not remove the system Python from *any* version of OS X. System Pythons are installed in `/System/Library/Frameworks` (which you should never modify), not `/Library/Frameworks`. – Ned Deily Jun 01 '16 at 06:30
-
1a coworker of mine screwed up their python installation and had to also clear out `/usr/local/lib/python2.7/site-packages` in addition to the above. – Lorkenpeist Jul 13 '16 at 21:47
-
9`brew doctor` can also be used to find the unused symlinks. – Shubham Kushwah Jul 02 '18 at 17:42
-
1@NedDeily in the last line of Step 3 I received approximately 20 messages along the lines of `rm: 2to3-2: Permission denied` `rm: 2to3-2.7: Permission denied` `rm: easy_install: Permission denied`. Does this matter? is there a way to get around it? (maybe add `sudo` somewhere?) – stevec Jul 24 '18 at 07:40
-
As alternative for step 3, this should be a safer command that avoids choking on unexpected filenames in the directory: `sudo find /usr/local/bin -maxdepth 1 -lname "*/Library/Frameworks/Python.framework/Versions/3.7/bin/*" -delete` – Lekensteyn Oct 13 '18 at 23:22
-
1@user5783745, you can add a `sudo` before `rm`. – Vivek Subramanian Dec 13 '18 at 21:42
-
Need to know if `/usr/local/bin/python2.7` should be left behind or not. Or if `/usr/bin/python2.7` is good enough? – John Greene Mar 20 '19 at 15:33
-
1@EgbertS, Step 3 above should remove `/usr/local/bin/python2.7` if it points to the python.org installed 2.7. The `/usr/local/` hierarchy is reserved for third-party files, not Apple-supplied macOS files. `/usr/bin/python2.7` is part of the Apple-supplied system Python and should not be altered. – Ned Deily Mar 21 '19 at 20:15
-
2Thank you, thank you @Martijn Pieters. I almost trashed my Mac. I was trying to install cx_Oracle and it defaulted to python2.7, but I'm working with Python 3.7. There is no need to uninstall Python 2.7. Just install Python3.x and use: `python3 -m pip install cx_Oracle --upgrade` instead of `python -m pip install cx_Oracle --upgrade` (notice the 3 indicates installation for Python 3.x). – Doris Gammenthaler Jul 17 '19 at 14:21
-
If you followed these commands and the system stoped working properly, you may not need to reinstall the OS, instead reset your user profile, create a new admin account on the MAC. login with the new account and then rename your old profile name under /users. Now restart your computer and login to your old user again and you should get new settings. – Gth lala Sep 26 '19 at 17:12
-
Substitute the version of Python you want to install... e.g. instead of 2.7 use 3.8 – Tim Feb 07 '20 at 16:59
-
Wow! Be very careful uninstalling python required for the Mac OS. Thanks for this bold warning. Your comment saved me! – Erich Meissner Apr 26 '20 at 20:44
-
If you just don't want Terminal to default to Python 2.7, use pyenv: `pyenv install 3.8.2 && pyenv global 3.8.2 && echo -e 'if command -v pyenv 1>/dev/null 2>&1; then\n eval "$(pyenv init -)"\nfi' >> ~/.bashrc` – uclagamer May 02 '20 at 13:06
-
What should i do if after all this steps python 2.7 still didn't deleted? – Mary Brykina Jun 05 '20 at 20:34
-
1Ok.. i've found this answer AFTER i've tried to remove the /System and /usr/bin python and got `Operation not permitted`. Thank god mac saved me from my stupidity – krulik Jun 11 '20 at 11:59
-
1After all these steps: `
% Python --version Python 2.7.16` – ScottyBlades Dec 09 '20 at 23:02 -
It should be made clearer not to follow these steps above, now I have to reinstall my entire macOS. – Oba Api Dec 02 '21 at 03:09
-
UPDATE EVERYONE: MacOS Monterary 12.3 comes without the system provided Python 2.7. Gave me a headache thinking that I accidentally uninstalled it somehow and my system was trashed. – undevable Apr 18 '23 at 01:21
This one works:
cd /usr/local/bin/
ls -l /usr/local/bin | grep '../Library/Frameworks/Python.framework/Versions/2.7' | awk '{print $9}' | tr -d @ | xargs rm
Description:
It list all the links, removes @
character and then removes them.
-
1I tried every answer provided here, and this is the one that finally did the trick. – jtsmith1287 Jan 09 '13 at 16:19
Create the symlink to latest version
ln -s -f /usr/local/bin/python3.8 /usr/local/bin/python
Close and open a new terminal
and try
python --version

- 1,547
- 1
- 13
- 24
-
5Thanks a lot and the same way goes for pip " ln -s -f /usr/local/bin/pip3 /usr/local/bin/pip " then " pip --version" also if you want to upgrade pip use this command "pip install --upgrade pip" – Moh Alaraabi May 22 '20 at 19:09
-
2
-
1
-
1
-
1It requires Super User privilege so you need command "sudo" for that – Haseeb Mir Jan 27 '23 at 22:45
Trying to uninstall Python with
brew uninstall python
will not remove the natively installed Python but rather the version installed with brew
.

- 8,525
- 5
- 47
- 53

- 7,189
- 2
- 26
- 44
-
I had to do this multiple times to get rid of all the random versions I had – Kevin Danikowski Apr 25 '21 at 18:11
-
You can also uninstall a specific version with `brew uninstall python@3.8` – Kevin Danikowski Apr 25 '21 at 18:17
If you installed it using the PKG installer, you can do:
pkgutil --pkgs
or better:
pkgutil --pkgs | grep org.python.Python
which will output something like:
org.python.Python.PythonApplications-2.7
org.python.Python.PythonDocumentation-2.7
org.python.Python.PythonFramework-2.7
org.python.Python.PythonProfileChanges-2.7
org.python.Python.PythonUnixTools-2.7
you can now select which packages you will unlink (remove).
This is the unlink documentation:
--unlink package-id
Unlinks (removes) each file referenced by package-id. WARNING: This command makes no attempt to perform reference counting or dependency analy-
sis. It can easily remove files required by your system. It may include unexpected files due to package tainting. Use the --files command first
to double check.
In my example you will type
pkgutil --unlink org.python.Python.PythonApplications-2.7
pkgutil --unlink org.python.Python.PythonDocumentation-2.7
pkgutil --unlink org.python.Python.PythonFramework-2.7
pkgutil --unlink org.python.Python.PythonProfileChanges-2.7
pkgutil --unlink org.python.Python.PythonUnixTools-2.7
or in one single line:
pkgutil --pkgs | grep org.python.Python | xargs -L1 pkgutil -f --unlink
Important: --unlink is not available anymore starting with Lion (as of Q1`2014 that would include Lion, Mountain Lion, and Mavericks). If anyone that comes to this instructions try to use it with lion, should try instead to adapt it with what this post is saying: https://wincent.com/wiki/Uninstalling_packages_(.pkg_files)_on_Mac_OS_X

- 1
- 1

- 1,090
- 1
- 12
- 23
-
4Unfortunately, depending on `pkgutil` will not remove all files installed by the Python installer because some of them are created during the installation postflight scripts and, as such, are not registered. – Ned Deily Oct 06 '14 at 04:29
No need to uninstall it or going crazy with symbolic links, just use an alias
. I faced the same problem when upgrading to python 3.7.1.
Just install the new python version using brew install python
then in your .bash_profile
create an alias pointing to the new python version; like this: alias python="/usr/local/bin/python3"
then save and run source ~/.bash_profile
.
Done.

- 2,345
- 3
- 25
- 39
In regards to deleting the symbolic links, I found this to be useful.
find /usr/local/bin -lname '../../../Library/Frameworks/Python.framework/Versions/2.7/*' -delete

- 34,416
- 17
- 114
- 136

- 129
- 1
- 2
-
this is a much better idea than parsing the output of `ls` as in the accepted answer – SpinUp __ A Davis Mar 29 '19 at 20:22
-
I keep getting "permission denied" from the above answers. But this one paired with `sudo` did it for me. Thanks! – Loqz Mar 08 '22 at 20:00
I faced the same problem when upgrading to python 3.9 from python 2.7.16 Just install the new python version using brew install python or download and install for your OS then
-
sudo rm -rf /Library/Frameworks/Python.framework/Versions/2.7
-
sudo rm -rf "/Applications/Python 2.7"
-
ls -l /usr/local/bin | grep '../Library/Frameworks/Python.framework/Versions/2.7'
then check ->
python --version
in your
.bash_profile
create an alias pointing to the new python version; like this:alias python="/usr/local/bin/python3"
then save and run source
~/.bash_profile
.check ->
python --version
all set now

- 19,327
- 10
- 37
- 52

- 209
- 2
- 6
No need to uninstall old python versions.
Just install new version say python-3.3.2-macosx10.6.dmg and change the soft link of python to newly installed python3.3
Check the path of default python and python3.3 with following commands
"which python" and "which python3.3"
then delete existing soft link of python and point it to python3.3

- 9,291
- 3
- 58
- 40
-
13Thanks, but this doesn't answer my question. The question is not whether I need to uninstall an old python versions in order to install a new version. – Jan Deinhard Sep 28 '13 at 17:58
-
2This seems the safest approach, since for me, mucking with what the OS puts on the machine doesn't usually turn out so well. I, too, "got the install package from http://python.org" after encountering syntax issues from python3 statements in a python2 shell. My first thought was to remove python2 and use python3, instead. However, from prior posts that confirms the dangers of that action. This was the better solution for me and follows the idea of "use links to reroute behaviour". Also, the python3 shell was already installed, just had to type "python3" instead of "python" at the prompt. – Mark Longmire Jan 23 '15 at 17:53
-
4
On a MacOS where python3
was installed with brew
:
sudo ln -s -f /opt/homebrew/bin/python3 /usr/local/bin/python
sudo ln -s -f /opt/homebrew/bin/pip3 /usr/local/bin/pip
Reopen terminal
python --version
pip --version

- 1,171
- 1
- 11
- 7
-
1This is the best answer in here. Pretty simple and just works! Thank you. – Mrinal Roy Feb 20 '22 at 07:34
Onur Güzel provides the solution in his blog post, "Uninstall Python Package from OS X.
You should type the following commands into the terminal:
sudo rm -rf /Library/Frameworks/Python.framework
cd /usr/local/bin
ls -l . | grep '../Library/Frameworks/Python.framework' | awk '{print $9}' | xargs sudo rm
sudo rm -rf "/Applications/Python x.y"
where command x.y is the version of Python installed. According to your question, it should be 2.7.
In Onur's words:
WARNING: This commands will remove all Python versions installed with packages. Python provided from the system will not be affected.
If you have more than 1 Python version installed from python.org, then run the fourth command again, changing "x.y" for each version of Python that is to be uninstalled.
-
That solved my issue, I have 2.7.10 and brew installed 2.7.15 and when I ran "python" the 2.7.10 was still showing up not 2.7.15, after your help all is working now, thank you – Radek Aug 01 '18 at 18:01
-
This was the solution for my issue. I had a 3.8 installed and could not remember how it was installed. Now nice and clean with python from brew. – jj2f1 Jul 06 '22 at 18:51
This is what worked for me on Mac OS
Download the latest Python 3.x from https://www.python.org/downloads/mac-osx/
Install Python 3.x by going through the Installation Steps that show up when you click on the installer
ln -s -f /usr/local/bin/python3.9 /usr/local/bin/python
ln -s -f /usr/local/bin/pip3 /usr/local/bin/pip
Open a new terminal window and verify
python --version
. Should say 3.x
For step 3, confirm the path for your existing python executable by checking the output of which python

- 9,362
- 4
- 45
- 65
Note: If you installed Python using Homebrew, then you can follow the following steps, otherwise look for another solution!
To uninstall Python 2.7.10 which you installed using Homebrew, then you can simply issue the following command:
brew uninstall python
Similarly, if you want to uninstall Python 3 (which you installed using Homebrew):
brew uninstall --force python3

- 15,395
- 32
- 113
- 196

- 173
- 3
- 12
If you're thinking about manually removing Apple's default Python 2.7, I'd suggest you hang-fire and do-noting: Looks like Apple will very shortly do it for you:
Python 2.7 Deprecated in OSX 10.15 Catalina
Python 2.7- as well as Ruby & Perl- are deprecated in Catalina: (skip to section "Scripting Language Runtimes" > "Deprecations")
https://developer.apple.com/documentation/macos_release_notes/macos_catalina_10_15_release_notes
Apple To Remove Python 2.7 in OSX 10.16
Indeed, if you do nothing at all, according to The Mac Observer, by OSX version 10.16, Python 2.7 will disappear from your system:
https://www.macobserver.com/analysis/macos-catalina-deprecates-unix-scripting-languages/
Given this revelation, I'd suggest the best course of action is do nothing and wait for Apple to wipe it for you. As Apple is imminently about to remove it for you, doesn't seem worth the risk of tinkering with your Python environment.
NOTE: I see the question relates specifically to OSX v 10.6.4, but it appears this question has become a pivot-point for all OSX folks interested in removing Python 2.7 from their systems, whatever version they're running.

- 3,580
- 3
- 25
- 24
-
2
-
1it seems that there will be no 10.16, but 11.0 (Big Sur) directly. We are still waiting! – Amr ALHOSSARY Oct 16 '20 at 06:54
Caution when trying to remove certain python library, Mac OS needs python! DO NOT remove any Python versions in the following folders:
/usr/bin
system/Library
These Python 2.7 versions are installed by Apple and used by Mac OS and other software. Deleting Python from these directories can break your system.

- 31
- 3
Here you will see all the preinstalled versions of python including 2.3, 2.4 and even 2.7.
/System/Library/Frameworks/Python.framework/Versions
But, even with sudo I do not think so, you will be able to remove them. You will get an error - Operation not permitted

- 996
- 15
- 25
Install the new python version using brew install python In .bash_profile or .zprofile create an alias like this: alias python="/usr/local/bin/python3" Done.

- 91
- 3