如何在Mac OS X 10.6.4上卸载Python 2.7?

本文翻译自:How to uninstall Python 2.7 on a Mac OS X 10.6.4?

I want to completely remove Python 2.7 from my Mac OS X 10.6.4. 我想从Mac OS X 10.6.4中完全删除Python 2.7。 I managed to remove the entry from the PATH variable by reverting my .bash_profile . 我设法通过还原.bash_profilePATH变量中删除了该条目。 But I also want to remove all directories, files, symlinks, and entries that got installed by the Python 2.7 install package. 但是我也想删除所有由python 2.7安装包安装的目录,文件,符号链接和条目。 I've got the install package from http://www.python.org/ . 我从http://www.python.org/获得了安装包。 What directories/files/configuration file entries do I need to remove? 我需要删除哪些目录/文件/配置文件条目? Is there a list somewhere? 某处有清单吗?


#1楼

参考:https://stackoom.com/question/G1c1/如何在Mac-OS-X-上卸载Python


#2楼

This one works: 这个作品:

cd /usr/local/bin/
ls -l /usr/local/bin | grep '../Library/Frameworks/Python.framework/Versions/2.7' | awk '{print $9}' | tr -d @ | xargs rm

Description: It list all the links, removes @ character and then removes them. 说明:列出所有链接,删除@字符,然后删除它们。


#3楼

If you installed it using the PKG installer, you can do: 如果使用PKG安装程序安装了它,则可以执行以下操作:

pkgutil --pkgs

or better: 或更好:

pkgutil --pkgs | grep org.python.Python

which will output something like: 这将输出类似:

org.python.Python.PythonApplications-2.7
org.python.Python.PythonDocumentation-2.7
org.python.Python.PythonFramework-2.7
org.python.Python.PythonProfileChanges-2.7
org.python.Python.PythonUnixTools-2.7

you can now select which packages you will unlink (remove). 您现在可以选择要取消链接(删除)的软件包。

This is the unlink documentation: 这是取消链接文档:

 --unlink package-id
             Unlinks (removes) each file referenced by package-id. WARNING: This command makes no attempt to perform reference counting or dependency analy-
             sis. It can easily remove files required by your system. It may include unexpected files due to package tainting. Use the --files command first
             to double check.

In my example you will type 在我的示例中,您将输入

pkgutil --unlink org.python.Python.PythonApplications-2.7
pkgutil --unlink org.python.Python.PythonDocumentation-2.7
pkgutil --unlink org.python.Python.PythonFramework-2.7
pkgutil --unlink org.python.Python.PythonProfileChanges-2.7
pkgutil --unlink org.python.Python.PythonUnixTools-2.7

or in one single line: 或一行:

pkgutil --pkgs | grep org.python.Python | xargs -L1 pkgutil -f --unlink

Important: --unlink is not available anymore starting with Lion (as of Q1`2014 that would include Lion, Mountain Lion, and Mavericks). 重要提示:--unlink从Lion(从2014年第一季度开始,包括Lion,Mountain Lion和Mavericks)不再可用。 If anyone that comes to this instructions try to use it with lion, should try instead to adapt it with what this post is saying: https://wincent.com/wiki/Uninstalling_packages_(.pkg_files)_on_Mac_OS_X 如果涉及此说明的任何人都尝试将其与狮子一起使用,则应尝试改编本文所讲的内容: https : //wincent.com/wiki/Uninstalling_packages_(.pkg_files)_on_Mac_OS_X


#4楼

No need to uninstall old python versions. 无需卸载旧的python版本。

Just install new version say python-3.3.2-macosx10.6.dmg and change the soft link of python to newly installed python3.3 只需安装新版本,说python-3.3.2-macosx10.6.dmg并将python的软链接更改为新安装的python3.3

Check the path of default python and python3.3 with following commands 使用以下命令检查默认python和python3.3的路径

"which python" and "which python3.3" “哪个python”和“哪个python3.3”

then delete existing soft link of python and point it to python3.3 然后删除python的现有软链接并将其指向python3.3


#5楼

关于删除符号链接,我发现这很有用。

find /usr/local/bin -lname '../../../Library/Frameworks/Python.framework/Versions/2.7/*' -delete

#6楼

Note : If you installed Python using Homebrew, then you can follow the following steps, otherwise look for another solution! 注意如果使用Homebrew安装了Python,则可以按照以下步骤操作,否则请寻找其他解决方案!


To uninstall Python 2.7.10 which you installed using Homebrew, then you can simply issue the following command: 要卸载使用Homebrew安装的Python 2.7.10,可以简单地发出以下命令:

brew uninstall python

Similarly, if you want to uninstall Python 3 (which you installed using Homebrew): 同样,如果要卸载Python 3(使用Homebrew安装),请执行以下操作:

brew uninstall --force python3
  • 1
    点赞
  • 0
    评论
  • 0
    收藏
  • 扫一扫,分享海报

参与评论 您还未登录,请先 登录 后发表或查看评论
©️2022 CSDN 皮肤主题:1024 设计师:我叫白小胖 返回首页
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、C币套餐、付费专栏及课程。

余额充值