简体   繁体   中英

How can I uninstall python3.9 which installed by macOS 64-bit Intel installer?

I installed Python 3.9.2 by using macOS 64-bit Intel installer .

I can find the path of the Python 3.9 binary file.

 ⚡  which python3.9                                                            
/usr/local/bin/python3.9

How can I uninstall it completely? Which directories and files should I remove?

You can find the installed files using the following:

List Packages with:

pkgutil --pkgs

Find files installed for your Python package

pkgutil --files yourpythonpackage.pkg

Delete the related files and run:

sudo pkgutil --forget yourpythonpackage.pkg

From my tests I can see:

pkgutil --pkgs | grep python

org.python.Python.PythonUnixTools-3.9
org.python.Python.PythonApplications-3.9
org.python.Python.PythonDocumentation-3.9
org.python.Python.PythonFramework-3.9

Files:

DIR: /Library/Frameworks/Python.framework/Versions/3.9/bin

2to3
2to3-3.9
idle3
idle3.9
pydoc3
pydoc3.9
python3
python3-config
python3.9
python3.9-config

DIR: /Applications/Python\ 3.9/
DIR: /Library/Frameworks/Python.framework/Versions/3.9

(Check these two latest from packages PythonDocumentation-3.9 and PythonFramework-3.9 )

In my case just deleting /Applications/Python\ 3.9/ and /Library/Frameworks/Python.framework was enough.

I am not sure if this method can delete all files related to python 3.9 . But it can get me back to the python version pre-installed on the OSX system.

I will rm -rf below directories and files:

/usr/local/bin/python3.9-config
/usr/local/bin/python3.9
/usr/local/bin/pip3.9
/usr/local/bin/pydoc3.9
/usr/local/idle3.9
/Library/Frameworks/Python.framework/Versions/3.9

If you have installed brew , you can run brew doctor to help you to some cleanup work.

☁  python-codelab [master] ⚡  brew doctor
Please note that these warnings are just used to help the Homebrew maintainers
with debugging if you file an issue. If everything you use Homebrew for is
working fine: please don't worry or file an issue; just ignore this. Thanks!

Warning: Broken symlinks were found. Remove them with `brew cleanup`:
  /usr/local/bin/2to3
  /usr/local/bin/2to3-3.9
  /usr/local/bin/easy_install-3.9
  /usr/local/bin/idle3
  /usr/local/bin/idle3.9
  /usr/local/bin/pip3
  /usr/local/bin/pydoc3
  /usr/local/bin/pydoc3.9
  /usr/local/bin/python3-config
☁  python-codelab [master] ⚡  python3 --version      
Python 3.8.2

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM