简体   繁体   English

彻底卸载Mac上的Python 3

[英]Completely uninstall Python 3 on Mac

I installed Python 3 on Mac and installed some packages as well.我在 Mac 上安装了 Python 3 并安装了一些软件包。 But then I see AWS lamda does not support Python 3 so I decided to downgrade.但后来我看到 AWS lamda 不支持 Python 3 所以我决定降级。 I removed Python3 folder in Applications and cleared the trash.我删除了应用程序中的 Python3 文件夹并清除了垃圾。 But still I see a folder named 3 in /Library/Frameworks/Python.framework/Versions which is causing problems, such as this:但是我仍然在/Library/Frameworks/Python.framework/Versions中看到一个名为 3 的文件夹,它导致了问题,例如:

  $ python3 -m pip install virtualenv
 Requirement already satisfied: virtualenv in      /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages (20.14.1)
 Requirement already satisfied: platformdirs<3,>=2 in /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages (from virtualenv) (2.5.2) 

So my question is how do I completely uninstall python 3 from my Mac?所以我的问题是如何从我的 Mac 上完全卸载 python 3?

Removing the app does not completely uninstall that version of Python.删除应用程序并不会完全卸载该版本的 Python。 You will need to remove the framework directories and their symbolic links.您将需要删除框架目录及其符号链接。

Deleting the frameworks删除框架

sudo rm -rf /Library/Frameworks/Python.framework/Versions/[version number] replacing [version number] with 3.10 in your case. sudo rm -rf /Library/Frameworks/Python.framework/Versions/[version number]替换为 3.10。

Removing symbolic links删除符号链接

To list the broken symbolic links.列出损坏的符号链接。

ls -l /usr/local/bin | grep '../Library/Frameworks/Python.framework/Versions/[version number]'

And to remove these links:并删除这些链接:

cd /usr/local/bin

ls -l /usr/local/bin | grep '../Library/Frameworks/Python.framework/Versions/[version number]' | awk '{print $9}' | tr -d @ | xargs rm*

As always, please be wary of copying these commands.与往常一样,请小心复制这些命令。 Please make sure the directories in the inputs are actual working directories before you execute anything.在执行任何操作之前,请确保输入中的目录是实际的工作目录。

The general idea in the end is to remove the folders and symlinks, and you're good to go.最后的一般想法是删除文件夹和符号链接,你对go很好。

Here is another response addressing this process: How to uninstall Python 2.7 on a Mac OS X 10.6.4?这是解决此过程的另一个响应: 如何在 Mac OS X 10.6.4 上卸载 Python 2.7?

# The version of Python that you want to delete 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

Uninstalling Python From MacOS从 MacOS 卸载 Python


another way to uninstall python from MacOS is by using tools such as...从 MacOS 卸载 python 的另一种方法是使用诸如...

App Cleaner & Uninstaller应用清理器和卸载器

or要么

Clean My Mac清洁我的 Mac

once you have installed one of them it should be quite simple to uninstall python or almost any other software from your Mac!一旦安装了其中之一,从 Mac 上卸载 python 或几乎所有其他软件应该非常简单!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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