在 Mac 上将 Python 升级到 2.6

发布于 2024-08-07 00:09:59 字数 81 浏览 5 评论 0 原文

我想将 OS X Leopard 附带的默认 python 安装 (2.5.1) 升级到最新版本。请让我知道如何实现这一目标。

谢谢

I'd like to upgrade the default python installation (2.5.1) supplied with OS X Leopard to the latest version. Please let me know how I can achieve this.

Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(7

过潦 2024-08-14 00:10:00

Mac OSX 的标准 http://python.org 安装将愉快地与“共存”系统蟒蛇”。如果你让安装程序更改你的路径,当你从终端提示符运行 python 时,它会

 /Library/Frameworks/Python.framework/Versions/2.6/bin/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

 /Library/Frameworks/Python.framework/Versions/2.6/bin/python

However, this won't interfere with anything that OSX itself does with python, which correctly hardwires the path to the version that it installs.

一场信仰旅途 2024-08-14 00:10:00

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.

最初的梦 2024-08-14 00:09:59

当操作系统与某些特定的 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.* or 3.*, 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 say python 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).

疧_╮線 2024-08-14 00:09:59

不要升级。

  1. 安装 ActivePython (其中 与其他人共存)。
  2. 打开终端
  3. 类型python2.6

Don't upgrade.

  1. Install ActivePython (which co-exists with others).
  2. Open Terminal
  3. Type python2.6
不打扰别人 2024-08-14 00:09:59

我建议你保留“默认”,并将 Python 安装在 /usr/local/bin 中。

  1. 下载 python
  2. 解压
  3. ./configure
  4. make
  5. sudo make install

完成。

由于 /usr/local/bin 在 $PATH 中位于 /usr/bin 之前,因此当您键入 python 时将调用 2.6,但操作系统将保持稳定...

May I suggest you leave the "Default" be, and install Python in /usr/local/bin.

  1. Download python
  2. Unzip it
  3. ./configure
  4. make
  5. sudo make install

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...

表情可笑 2024-08-14 00:09:59

您有多种选择

  • 使用MacPortsFink,例如:

    sudo port install python2.6
    
  • python.org
  • 来源

    tar xzvf Python-2.6.3.tgz
    cd Python-2.6.3
    ./配置&&制作&&须藤进行安装
    

You have a number of options

  • Install with MacPorts or Fink, e.g.:

    sudo port install python2.6
    
  • Install from the disc image from python.org
  • Install from source:

    tar xzvf Python-2.6.3.tgz
    cd Python-2.6.3
    ./configure && make && sudo make install
    
小ぇ时光︴ 2024-08-14 00:09:59

最好的方法是使用 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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文