我是一个业余爱好者,有一台 mac,我想重置所有 python。我想删除操作系统中mac上已经存在的版本以外的所有版本。我希望 python 版本就像我刚刚获得了一个新的操作系统一样。
谢谢!!!
我是一个业余爱好者,有一台 mac,我想重置所有 python。我想删除操作系统中mac上已经存在的版本以外的所有版本。我希望 python 版本就像我刚刚获得了一个新的操作系统一样。
谢谢!!!
Unfortunately, there is no one-size-fits all answer here, because there are a number of different ways to install Python, many of which do not come with uninstallers.
Everything Apple installs is inside /System
, or inside /usr
but not /usr/local
. So, those are the areas not to touch, no matter what.
Apple's Pythons put their system-wide site packages in /Library/Python/X.Y
. Some third-party Pythons may also use site packages there. If you've mixed and matched, there's no way to straighten that up except to wipe the whole thing. To restore these directories to a clean slate, each one should have nothing but a site-packages
directory, in which there should be nothing but a README
and a easy-install.pth
and/or Extras.pth
.
Some third-party packages that have binary installers meant to work with Apple's Python install things into /usr/local/lib/pythonX.Y/site-packages
. Again, these are shared with other Python installations. If you want to restore to a clean slate, delete everything in any such directory.
If you've configured user-specific site packages, or virtual environments, you should know which ones go with which Python—and, if you don't, just scrap them entirely.
Apple's Pythons install or link any scripts/executables that come with any site packages into /usr/local/bin
. Unfortunately, most third-party Pythons will do the same thing. And of course non-Python executables installed from elsewhere also end up here. The only way to really be safe is to only delete files here that:
/Library/Frameworks/Python.framework
or into a site-packages directory./System
or /usr/bin
).otool -L
).If you're also trying to kill site packages installed into Apple Python, symlinks, shebangs, and executable links that point to Apple Python can go too.
Anything installed with a package manager—Homebrew, MacPorts, Fink, etc.—should be uninstalled the same way: brew uninstall python
, sudo port uninstall python3.2
, etc.
Anything that has an uninstaller (either inside a Python X.Y
or MacPython
or similar folder in Applications
, or on the original disk image), obviously run that.
Meanwhile, non-Apple standard framework builds—that is, any binary installer from python.org, or anything you build yourself according to simple instructions—will put files into the following places:
/Library/Framework/Python.framework/X.Y
. This is the main guts. Kill it. In fact, kill the whole Python.framework
to remove all versions at once.Non-framework builds by default install everything into /usr/local; they will be effectively the same as framework builds, but with no /Library/Framework/Python.framework/X.Y
, and instead a /usr/local/lib/pythonX.Y
that contains things besides just site-packages. Kill those things.
Third-party installations like Enthought or (x,y), you will have to figure out what you have and find the uninstallation instructions on their site. There's really no way around that.