![[Formales]]
![[zImagesCloud/uninstall_python_on_mac_os__576595621.png]]
[Completely uninstall Python 3 on a Mac](https://stackoverflow.com/questions/72005302/completely-uninstall-python-3-on-mac)<br> From: *StackOverflow*
> [!CITE] Targeted approach uninstalling a specific version of Python installed on macOS, especially if it was installed using the official Python installer from Python.org.
# Complete uninstall python
## How
```
python_version_number=3.10 sudo rm -rf /Library/Frameworks/Python.framework/Versions/${python_version_number}/ sudo rm -rf "/Applications/Python ${python_version_number}/" cd /usr/local/bin && ls -l | grep "/Library/Frameworks/Python.framework/Versions/${python_version_number}" | awk '{print $9}' | sudo xargs rm
```
## Explanation
### python_version_number=3.10
This sets a variable python_version_number with the value 3.10, which you want to uninstall.
### sudo rm -rf /Library/Frameworks/Python.framework/Versions/${python_version_number}/
This command removes the Python framework for the specified version from /Library/Frameworks/Python.framework/Versions/. It's using the variable you set, so it would expand to /Library/Frameworks/Python.framework/Versions/3.10/.
### sudo rm -rf "/Applications/Python ${python_version_number}/"
This removes the Python application directory for the specified version from /Applications/, in this case, /Applications/Python 3.10/.
### cd /usr/local/bin && ls -l | grep "/Library/Frameworks/Python.framework/Versions/${python_version_number}" | awk '{print $9}' | sudo xargs rm
> [!multi-column]
>
>> [!BLANK]
>> ```zsh
>> cd /usr/local/bin
>> ```
>
>
>> Changes the directory to /usr/local/bin.
> [!multi-column]
>
>> [!BLANK]
>> ```zsh
>> ls -l
>> ```
>
>
>> Lists all files in /usr/local/bin.
> [!multi-column]
>
>> [!BLANK]
>> ```zsh
>> grep "/Library/Frameworks/Python.framework/Versions/${python_version_number}"
>> ```
>
>
>> Filters the list to include only those files that are symbolic links to the Python version you are removing.
> [!multi-column]
>
>> [!BLANK]
>> ```zsh
>> awk '{print $9}'
>> ```
>
>
>> Extracts the names of these files.
> [!multi-column]
>
>> [!BLANK]
>> ```zsh
>> sudo xargs rm
>> ```
>
>
>> Removes the files (symbolic links) that were identified.
# Considerations
## Run With Caution
These commands involve **sudo rm -rf**, which is very powerful and can cause irreparable damage to your system if used incorrectly. Always double-check the version number and paths.
## Backup
It's a good practice to backup important data before running such commands.
## System Python
> [!DANGER] Do not remove the System Python
> Ensure you are not removing the system Python. macOS uses Python for some system tasks, and removing or altering the system Python can cause issues with your operating system.
## Dependencies
Be aware that other applications might depend on the Python version you're removing. Ensure that you're not breaking any dependencies.
## Are you certain?
If you're certain that the version 3.10 is the one you installed and want to remove, and it's not being used by any critical applications or processes, these commands should work for that purpose.