Uninstall Python3 on a Mac

Hi,
I have removed all Python 3.10.1 files.

But there is still a reference to /Library/Frameworks/Python.framework/Versions/3.10/bin
in my $path

How can I remove it ?

I can’t see it by
sudo nano /etc/paths
or if I check in etc/paths.d

Any idea ?
Thanks

Assuming you’re using the default shell.

  • For macOS Catalina or newer:

    $ nano $HOME/.zprofile
    
  • For macOS pre Catalina:

    $ nano $HOME/.bash_profile  # or...
    $ nano $HOME/.bash_login    # or...
    $ nano $HOME/.profile
    

The python.org installer patches your shell’s rc file by appending a line that prepends the Python path to your PATH environment variable. Note that the installer also makes a backup of your rc file before applying the patch. You can revert to the backed up rc file if you wish:

$ cd $HOME
$ ls .*.pysave
.zprofile.pysave                 # ls output from macOS Catalina or newer
$ cat .zprofile.pysave           # examine backed up rc file
$ mv .zprofile.pysave .zprofile  # revert to backed up rc file

Thanks a lot, .zprofile it is !

By the way it seems the backup didn’t work, I couldn’t find any pysave file in my home directory.

Thanks

1 Like

Good to hear :slight_smile:

Make sure you got the extra dot (.) in front of the star (*). Also make sure you cd to your home directory before ls'ing. Or you could try:

$ ls $HOME/.*.pysave

No match, there’s no .pysave file.
(not an issue for me)

Ok, that may happen if there was no rc file there in the first place.