我的 Mac OS X Mountain Lion 上的蟒蛇太多 [英] Too many pythons on my Mac OS X Mountain Lion

查看:61
本文介绍了我的 Mac OS X Mountain Lion 上的蟒蛇太多的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不久前更新到 Mountain Lion,之前使用过 python,现在我的计算机上安装了 8 个(是的,8 个)版本的 python.

I updated to Mountain Lion not long ago, and having used python previously, I now have 8 (yes, 8) versions of python installed on my computer.

$ ls -l /System/Library/Frameworks/Python.framework/Versions/
total 8
drwxr-xr-x   6 root  wheel  204 Jun 20 16:23 2.3
drwxr-xr-x  11 root  wheel  374 Aug 22 13:32 2.5
drwxr-xr-x  11 root  wheel  374 Aug 22 13:32 2.6
drwxr-xr-x  11 root  wheel  374 Aug 22 13:32 2.7
lrwxr-xr-x   1 root  wheel    3 Jul 29 17:41 Current -> 2.7

我很想删除所有这些并清理所有内容,并且我更喜欢设置到 Mountain Lion 附带的系统 python 的所有路径.我的目标是简单和干净.我已经尝试这样做了将近六个月,断断续续……网络上有许多解决方案"和脚本可用于解决此问题,但没有一个完全有效,甚至无法理解.谁能告诉我如何从我的 Mac 中删除这些不需要的 Python 版本,或者至少如何设置我的 Mac,以便一切顺利进入 Mac 系统版本的 python.我没有太多我特别需要使用的旧 Python 文件,但我注意到我在安装 Python 内容和运行 .py 脚本时遇到了麻烦,因为路径全都混淆了或类似的东西.

I would love to erase all of them and clean everything up, and I prefer to set all paths to the system python that comes with Mountain Lion. My goal is simplicity and cleanliness. I have been trying to do this for literally almost six months, off and on... there are a multitude of "solutions" and scripts available on the web for this problem, and none of them fully work or are even understandable. Can anyone tell me how to get these unwanted Python versions off of my Mac, or at least how to set my Mac so that everything goes nicely into the Mac system version of python. I don't have too many old Python files I particularly need to use, but I've noticed that I have trouble installing Python stuff and running .py scripts because the paths are all mixed up or something to that effect.

另外,我明白了:

$ echo $PATH
/Library/Frameworks/Python.framework/Versions/Current/bin:/Library/Frameworks/Python.framework/Versions/2.7/bin:/Library/Frameworks/Python.framework/Versions/Current/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/opt/X11/bin:/usr/texbin:/usr/local/mysql/bin

……有点吓人.

感谢您的帮助.我熟悉 UNIX shell 脚本,对系统管理的东西有中级理解……但不高级.我是 R 中的程序员,所以我知道如何编程以及所有这些.感谢任何建议!

Thanks for your help. I am familiar with UNIX shell scripting and have a mid-level understanding of system admin stuff... but not advanced. I am a programmer in R so I know how to program and all of that. Appreciate any suggestions!

推荐答案

您实际上有 5 个,是的 5 个版本,而不是 8 个,而不是 8 个.这 5 个版本中的 4 个是操作系统的一部分,不应删除.所以你只有 1 个多余的,而不是 7 个.

You actually have 5, yes 5, versions, not 8, not 8. And 4 of those 5 are part of the OS and should never be removed. So you only have 1 excess, not 7.

ls -l /System/Library/Frameworks/Python.framework/Versions/
total 8
drwxr-xr-x   6 root  wheel  204 Jun 20 16:23 2.3
drwxr-xr-x  11 root  wheel  374 Aug 22 13:32 2.5
drwxr-xr-x  11 root  wheel  374 Aug 22 13:32 2.6
drwxr-xr-x  11 root  wheel  374 Aug 22 13:32 2.7
lrwxr-xr-x   1 root  wheel    3 Jul 29 17:41 Current -> 2.7

那是 4.一个符号链接 Current ->2.7 不是别的版本,又是同一个版本.这 4 个都随您的系统一起提供,并且可以由系统中的工具使用.你永远不应该删除它们,或者 /System 目录中的任何东西(或者启动它们的 /usr/bin 快捷方式).

That's 4. A symlink Current -> 2.7 is not another version, it's the same version again. These 4 all come with your system, and may be used by tools that are part of the system. You should not ever get rid of them, or anything else inside the /System directory (or the /usr/bin shortcuts that launch them).

与此同时,您的路径中有这些:

Meanwhile, you have these in your path:

/Library/Frameworks/Python.framework/Versions/Current/bin:
/Library/Frameworks/Python.framework/Versions/2.7/bin
/Library/Frameworks/Python.framework/Versions/Current/bin

那只是同一个版本的三个副本,很可能是来自 python.org 的官方 Python 2.7.我的猜测是您运行了一次旧式安装程序,然后运行了一次新安装程序.

That's just three copies of the same version, most likely the official Python 2.7 from python.org. My guess is that you ran the old-style installer once, and then ran the newer installer once.

但它们是如何到达那里的并不重要(除非是通过 Homebrew,在这种情况下只需 brew unlink python 就完成了).您可以按照 python.org 上的卸载说明删除它,然后您将再次只有最少的 4 个.

But it doesn't matter how they got there (unless it was through Homebrew, in which case just brew unlink python and you're done). You get rid of it by following the uninstall instructions at python.org, and then you will have only the minimal 4 again.

快速检查后,我在python.org上找不到曾经有简单卸载说明的页面,但基本上是这样的:

After a quick check, I can't find the page that used to have the simple uninstall instructions at python.org, but basically, it's this:

rm -rf /Library/Frameworks/Python.framework

然后您可以执行 ls -l/usr/local/bin |grep Python.frameworkrm 出现的一切.(您可以自动执行此操作,但最好准确查看您要删除的内容.)

You can then do an ls -l /usr/local/bin | grep Python.framework and rm everything that turns up. (You can automate that, but it's probably better to see exactly what you're deleting.)

您可能还想找到将额外内容添加到 PATH 中的内容.可能需要查看的地方是 ~/.bash_profile(python.org 安装程序在那里完成),类似的文件,如 ~/.bashrc~/.profile(其他人可能告诉你把它放在那里),可能还有 /etc/paths/etc/paths.d(你可能把它放在使其与 GUI 应用程序一起使用).

You may also want to find what's adding the extra stuff to your PATH. Likely places to look are ~/.bash_profile (where the python.org installers do it), similar files like ~/.bashrc or ~/.profile (where others may have told you to put it), and possibly /etc/paths or /etc/paths.d (where you may have put it to make it work with GUI apps).

这篇关于我的 Mac OS X Mountain Lion 上的蟒蛇太多的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆