python - OS X 上 Python 升级问题

标签 python macos

我有 OS X 10.6.6 Snow Leopard。 OS X 默认安装的 python 是 64 位模式下的 2.6.1。 Apple 很好地安装了多个 Python 扩展,例如 numpy 和 Apple Events 的多个框架。

大多数人不建议升级 OS X 上的默认 Perl,因为操作系统在发布时依赖于 Perl 的某些行为。 Python社区似乎更加乐观并且recommends :

The overwhelming recommendation of the "MacPython" community is to upgrade your Python by downloading and installing a newer version from the Python standard release page

我已经尝试过两次升级。第一次尝试是通过 MacPorts 安装 Python 2.7.1。第二个只是从Python standard release page直接下载Python 2.7.1。 .

事实:

  1. MacPorts 版本安装在 /opt/local/bin/python 中,框架位于 /opt
  2. 默认的 OS X python 2.6.1 和 2.5.4 保留在 /usr/bin
  3. /System/Library/Frameworks/Python.framework 具有适用于 python v 2.3、2.5、2.6 和“Current”的框架。 “当前”为空。
  4. 从 python 网站下载的文件安装在 /usr/local/bin 处,并且是指向 /Library/Frameworks/Python.framework/Versions 的链接 2.7
  5. 我的路径已设置,因此 MacPorts 版本位于路径中的第一个。

疑问和问题:

  1. MacPorts 版本无法运行pydocs -g。它失败并出现错误:TclError:堆栈空间不足(无限循环?) 我尝试下载 Tkinter 的 macports 版本,但仍然没有任何乐趣。有什么想法吗?
  2. 我可以迁移 Apple 安装的 Python 支持模块吗?还是需要手动重新安装每个模块?
  3. 我可以删除 /System/Library/Frameworks/Python.framework 中的 python 2.3 框架吗? /usr/bin 目录中似乎没有指向这些可执行文件的链接。
  4. 如果“MacPython”社区的建议是“升级”,为什么系统版本没有受到2.7.1的python下载影响?
  5. 一旦我弄清楚所有这些版本,在安装的不同版本的 python 之间共享模块的“最佳实践”是什么?

最佳答案

1. The MacPorts version cannot run pydocs -g. It fails with the error: TclError: out of stack space (infinite loop?) I have tried to download macports version of Tkinter but still no joy. Ideas?

我不是 MacPorts 的用户,所以我对此没有任何想法。

2. Can I migrate over the Apple installed python support modules or do I need to manually reinstall each one?

手动重新安装每一个。我建议将它们安装在一个或多个 virtualenv 环境中,以免污染您的全局 site-packages 目录。

3. Can I delete the python 2.3 framework in /System/Library/Frameworks/Python.framework? There does not seem to be a link to these executables in the /usr/bin directory.

我不会删除 /System/Library/Frameworks/ 中的任何内容。正如Alex Martelli in his answer to this SO question所述,“你不应该以任何方式篡改系统提供的Python。”

4. If the recommendation of the "MacPython" community is to "upgrade" why does the system version remain untouched by the python download of 2.7.1?

虽然他们使用“升级”这个词,但他们真正的意思是执行全新的安装,而不是使用/接触 Apple 安装的版本。

5. Once I figure out all these versions, what is 'best practice' on sharing modules between different versions of python that are installed?

virtualenv

有关如何安装 Python 和各种软件包的信息,请查看以下 StackOverflow 问题:

使用 Python.org DMG 将执行位于 /Library/Frameworks/Python.framework/ 中的 Python 框架安装。

关于python - OS X 上 Python 升级问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4696525/

相关文章:

mysql - 如何在外部磁盘(mac os)上存储带有mysql数据的命名docker卷?

objective-c - NSScrollView 跳转,在底部添加填充

macos - 如何在命令终止时调试 vimrc

macos - 可靠地创建 .DS_Store 文件

python - 使用 srid 4326 进行 GeoDjango 距离查询返回 'SpatiaLite does not support distance queries on geometry fields with a geodetic coordinate system.'

python - 获取多维数组中的最大子集

python - slqlalchemy UniqueConstraint VS 索引(唯一=真)

python : Fibonacci sequence using range(x, y,n)

python - 如何解决 Windows 上的 "NotImplementedError"urllib2/gevent 错误?

ruby - 无法在安装了 xcode 和 rvm 的 Mac OSX 10.9.1 上安装 Jekyll