MacOS – Re-install Python on macOS

data-recoveryinstallmacospython

I uninstalled Python on my Mac by moving all python-related files in my Mac (including system files) to the trash and emptying the trash. Now, I can't get Python 3 to work at all (despite reinstalling it). How can I get all of the deleted Python files back?

Update: I deleted the following files:

/Applications/Python
/Library/Frameworks/Python.framework
/usr/local/bin/py

thon

Best Answer

Ideally you can restore whatever you‘ve deleted from a backup.

If you removed the standard Python installation of macOS, boot into the Recovery Partition (if any) and reinstall macOS from there. This should leave your other files intact, it‘s not a bad idea to do a backup before nevertheless.

Alternatively, you can through Homebrew.

Once Homebrew is installed, run:

brew install python@2

That won't likely install the same 2.7 revision you were using.

If you need an exact match, or don't/can't use Homebrew; I'd build it from source (if so, comment for further instruction).

Python 2 is end of life by January 1st 2020. Please don’t use it unless you are sure you are using an OS default.


If I am not in mistake, as of June 2020 macOS 10.15.4 (i.e., not fully up to date) is still at Python 2.7 (2.7.16).

If you are at 10.15.5 or later you are welcome to comment your mileage.