在 Mac 上将 Python 升级到 2.6
我想将 OS X Leopard 附带的默认 python 安装 (2.5.1) 升级到最新版本。请让我知道如何实现这一目标。
谢谢
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
我想将 OS X Leopard 附带的默认 python 安装 (2.5.1) 升级到最新版本。请让我知道如何实现这一目标。
谢谢
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
接受
或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
发布评论
评论(7)
Mac OSX 的标准 http://python.org 安装将愉快地与“共存”系统蟒蛇”。如果你让安装程序更改你的路径,当你从终端提示符运行 python 时,它会
在它安装了。
The standard http://python.org install for Mac OSX will happily coexist with the "system python". If you let the installer change your paths, when you run python from a prompt in terminal, it will find the version at
However, this won't interfere with anything that OSX itself does with python, which correctly hardwires the path to the version that it installs.
我相信有几个选择。我喜欢的是使用 MacPorts 在我的 Mac 上安装替代 UNIX 软件,http://www.macports.org/< /a>——这样新软件就会安装在不同的目录中,并且不会因为苹果安装的版本而搞乱任何东西,而且 macports 也有一个很好的方法来保持安装的软件最新。我相信 MacPorts 也有助于处理依赖性。
I believe there are a few options. The one I like is to install alternative UNIX software on my Macs using MacPorts, http://www.macports.org/ -- this way the new software is installed in a different directory and won't mess up anything depending on the apple-installed version, and macports also has a nice way of keeping their installed software up to date. I believe MacPorts helps take care of dependencies as well.
当操作系统与某些特定的 Python 版本一起分发并将其用于某些操作系统功能时(如 Mac OS X 以及许多 Linux 发行版和 c 的情况),您不应该不篡改以任何方式使用系统提供的 Python(例如“升级”它等):而 Python 力求在任何主要版本(例如
2.*
或3.*)中向后兼容。 *
,这永远无法 100% 保证;您提供的操作系统已使用他们分发的特定 Python 版本彻底测试了所有功能,“由您决定”——您的操作系统供应商都没有; PSF 也不对可能对您的系统造成的任何损害承担任何责任,相反,正如其他答案已经建议的那样,安装“除了”系统之外的任何其他版本 - 为什么要篡改那个关键版本,并冒着破坏东西的风险。 ,安装其他系统是如此容易?!在典型的 Mac OS X 10.5 机器上(还没有将我的几台 Mac 升级到 10.6),我有 Apple 提供的 2.5,侧面有一个 2.4 以支持一些旧项目不值得费心去升级,最新的 2.6 是为了新东西,3.1 也是为了获得最新的——它们都安静地生活在一起,我只是明确地输入版本号,即使用 python2.6<当我想要特定版本时,在提示符下 /code> 。当您在 shell 提示符下输入
python
时,使用哪个版本取决于您(我个人更喜欢它的意思是“系统提供的 Python”,但这只是一个品味问题:通过设置路径,或 shell 别名,&c,你可以让它代表任何你想要的意思)。When an OS is distributed with some specific Python release and uses it for some OS functionality (as is the case with Mac OS X, as well as many Linux distros &c), you should not tamper in any way with the system-supplied Python (as in, "upgrading" it and the like): while Python strives for backwards compatibility within any major release (such as
2.*
or3.*
, this can never be 100% guaranted; your OS supplied tested all functionality thoroughly with the specific Python version they distribute; if you manage to alter that version, "on your head be it" -- neither your OS supplier nor the PSF accepts any responsibility for whatever damage that might perhaps do to your system.Rather, as other answers already suggested, install any other release you wish "besides" the system one -- why tamper with that crucial one, and risk breaking things, when installing others is so easy anyway?! On typical Mac OS X 10.5 machines (haven't upgraded any of my several macs to 10.6 yet), I have the Apple-supplied 2.5, a 2.4 on the side to support some old projects not worth the bother to upgrate, the latest 2.6 for new stuff, 3.1 as well to get the very newest -- they all live together in peace and quiet, I just type the release number explicitly, i.e. using
python2.6
at the prompt, when I want a specific release. What release gets used when at the shell prompt you just saypython
is up to you (I personally prefer that to mean "the system-supplied Python", but it's a matter of taste: by setting paths, or shell aliases, &c, you can make it mean whatever you wish).不要升级。
python2.6
Don't upgrade.
python2.6
我建议你保留“默认”,并将 Python 安装在 /usr/local/bin 中。
完成。
由于 /usr/local/bin 在 $PATH 中位于 /usr/bin 之前,因此当您键入 python 时将调用 2.6,但操作系统将保持稳定...
May I suggest you leave the "Default" be, and install Python in /usr/local/bin.
done.
Since /usr/local/bin comes before /usr/bin in the $PATH, you will invoke 2.6 when you type python, but the OS will remain stable...
您有多种选择
使用MacPorts或Fink,例如:
从 来源:
You have a number of options
Install with MacPorts or Fink, e.g.:
Install from source:
最好的方法是使用 macports (就像 Adam Rosenfield 在该线程中所述)。
您可以使用 macports 选择机制轻松地在 Python 版本之间切换:
$ sudo port select --set python pythonXY
要查看您可以使用上面的可用 Python 版本的列表和/或确认您正在使用哪个版本:
$ sudo port select --list python
要安装新的 Python 版本:
$ sudo port install pythonXY
The best is to use macports (just like Adam Rosenfield stated on this thread).
You can easily switch between Python versions using macports select mechanism:
$ sudo port select --set python pythonXY
To view the list of available Python versions you can use above and/or confirm which one you're using:
$ sudo port select --list python
To install a new Python version:
$ sudo port install pythonXY