简体   繁体   English

如何在OSX Mountain Lion上安装python 2.7.4

[英]How to install python 2.7.4 on OSX Mountain Lion

I tried installing python 2.7.4 by overwriting the native Apple's installation of python 2.7 by following this link (wolfpaulus.com), and as a result both easy_install and pip no longer work. 我尝试通过以下链接 (wolfpaulus.com)覆盖本机Apple的python 2.7安装来安装python 2.7.4,因此easy_install和pip都不再有效。

This link (apple.com) suggests the native Apple bundle should never be deleted. 此链接 (apple.com)建议永远不要删除原生Apple捆绑包。

Is it possible to restore python 2.7 supplied by Apple without reinstalling OSX? 是否可以在不重新安装OSX的情况下恢复Apple提供的python 2.7? Is there a definitive guide to upgrading python to 2.7.4 on OSX Lion? 是否有关于在OSX Lion上将python升级到2.7.4的权威指南? For instance, before breaking my set up I could install bumpy, django into 2.7.4, but matplotlib refused to install to anything but 2.7, either from binaries or source. 例如,在破坏我的设置之前,我可以将颠簸,django安装到2.7.4,但是matplotlib拒绝安装到2.7以外的任何东西,无论是来自二进制文件还是源代码。

Thanks. 谢谢。

It is absolutely not a good idea to replace Apples default python installation. 替换Apples默认的python安装绝对不是一个好主意。 If you have done, then you could try with the following command 如果已经完成,则可以尝试使用以下命令

" brew install python --framework " “brew install python --framework”

R [R

You should never remove anything in /System/Library or /usr (other than /usr/local ). 您永远不应删除/System/Library/usr中的任何内容(除了/usr/local )。 Files installed in those locations are managed by Apple as part of OS X. At worst you can fatally damage your OS X system; 安装在这些位置的文件由Apple作为OS X的一部分进行管理。最坏的情况是,您可能会严重损坏您的OS X系统; at best you are at risk of all of your changes being wiped out by the next software update. 充其量,您将面临下一次软件更新消除所有更改的风险。 In particular with Python, you've just wiped out Apple-supplied extensions to Python that are not available elsewhere. 特别是在Python中,你刚刚删除了Apple提供的Python扩展,这些扩展在其他地方都没有。 The right way to update a system component like Python is to install the new version at a different location, like the python.org Python installers do in /Library/Frameworks , and then manage access by modifying your shell PATH environment variable. 更新像Python这样的系统组件的正确方法是在不同的位置安装新版本,例如python.org Python安装程序在/Library/Frameworks ,然后通过修改shell PATH环境变量来管理访问。 Unfortunately, Apple does not make it easy to install individual components of OS X that have been mistakenly removed. 不幸的是,Apple不容易安装被错误删除的OS X的各个组件。 To properly restore all of the system Python that you've deleted, the easiest approach is to reinstall OS X itself. 要正确恢复已删除的所有系统Python,最简单的方法是重新安装OS X本身。

When you install another version of Python, you should also use it to install additional versions of pip or easy_install . 当您安装另一个版本的Python时,您还应该使用它来安装其他版本的pipeasy_install Generally, each Python version should have its own version of each. 通常,每个Python版本都应该有自己的版本。

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

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