Created
November 21, 2022 14:43
-
-
Save koola/5415a95cd3251fa298f8baf366eade8a to your computer and use it in GitHub Desktop.
Mac OS X uninstaller for default Python dmg
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
(( ${#} >= 0 )) || { | |
echo 'DISCLAIMER: USE THIS SCRIPT AT YOUR OWN RISK!' | |
echo 'THE AUTHOR TAKES NO RESPONSIBILITY FOR THE RESULTS OF THIS SCRIPT.' | |
echo 'Press Control-C to quit now.' | |
read | |
echo 'Re-running the script with sudo.' | |
echo 'You may be prompted for a password.' | |
sudo ${0} sudo | |
exit $? | |
} | |
# This will need to be executed as an Admin (maybe just use sudo). | |
version=$1 | |
[ -z $1 ] && { | |
echo ">>> Python version not specified; ${0} 3.10" | |
exit 0 | |
} | |
# Verify that Python version bom exists. Otherwise, don't do anything. | |
[ -e /var/db/receipts/org.python.Python.PythonApplications-${version}.bom ] || { | |
echo ">>> Python $version not found. Nothing to do." | |
exit 0 | |
} | |
echo '>>> Removing Python bom and plist files...' | |
for i in $(ls -f /var/db/receipts/ | grep "org.python.Python.*-${version}."); do | |
sudo rm -v /var/db/receipts/${i} | |
done | |
# Remove files and directories related to Python. | |
echo '>>> Removing Python files and directories...' | |
sudo rm -rfv /Library/Frameworks/Python.framework/Versions/${version} \ | |
"/Applications/Python ${version}" \ | |
~/.python_history | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment