在 mac OS Lion 上预装 python 2.6.7 的 numpy 和 scipy [英] numpy and scipy for preinstalled python 2.6.7 on mac OS Lion

查看:30
本文介绍了在 mac OS Lion 上预装 python 2.6.7 的 numpy 和 scipy的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

无论如何要在 Mac OS Lion 附带的 python 2.6.7 上安装 numpy 和 scipy?我知道 Lion 也有 Python 2.7.但我需要坚持使用 Python 2.6,因为我使用的模块不适用于 Python 2.7.

Is there anyway to install numpy and scipy on python 2.6.7 that comes with Mac OS Lion? I am aware that Lion has Python 2.7 as well. But I need to stick with Python 2.6 cause I am using a module that does not work on Python 2.7.

推荐答案

Lion 带有一个 easy_install 用于其每个 Python 实现:/usr/bin/easy_install-2.7 用于 /usr/bin/python2.7,同样用于 2.6 和 2.5.

Lion comes with an easy_install for each of its Python implementations: /usr/bin/easy_install-2.7 for /usr/bin/python2.7, and likewise for 2.6 and 2.5.

但是,scipy 需要 Fortran 编译器,而 Lion 没有提供其中之一.看来你在安装 numpy 之前必须有 Fortran 编译器,不然后面就不能安装 scipy 了.

However, scipy requires a Fortran compiler, and Lion doesn't come with one of those. It also looks like you have to have the Fortran compiler in place before installing numpy, or scipy can't be installed later.

首先,您需要 Xcode 命令行工具.(Apple 经常更改此包的名称——根据您的 Xcode 版本,它可能是Unix 开发工具"或CLI 开发工具链"等.)

First, you need the Xcode Command Line Tools. (Apple frequently changes the name of this package—it may be "Unix Development Tools", or "CLI Development Toolchain", etc., depending on your Xcode version.)

这些可以由 Xcode 自己安装.如果您使用的是 4.3.x,从 App Store 安装 Xcode 后,启动它,转到首选项、下载、组件,然后单击命令行工具"旁边的安装按钮.对于不同的版本,或者如果您想在没有 Xcode 的情况下安装它们,Homebrew 页面(见下文)解释了如何获取它们,或者您可以查看 Apple 的开发者网站.

These can be installed by Xcode itself. If you're using 4.3.x, after installing Xcode from the App Store, launch it, go to Preferences, Downloads, Components, and click the Install button next to "Command Line Tools". For different versions, or if you want to install them without Xcode, the Homebrew page (see below) explains how to get them, or you can look around Apple's developer site.

如果您已经有一个包管理器(Homebrew、MacPorts 或 Fink),请使用它.如果没有,请安装 Homebrew:

If you've already got a package manager (Homebrew, MacPorts, or Fink), use that. If you don't, install Homebrew:

curl https://raw.github.com/gist/323731/25f99360c7de3f72027d8fd07cb369b1c8756ea6/install_homebrew.rb -o /tmp/install_homebrew.rb
ruby /tmp/install_homebrew.rb
rehash

然后像这样安装gfortran:

Then install gfortran like this:

brew install gfortran

现在您已准备好安装 numpy 和 scipy.如果您更喜欢 pip 而不是 easy_install(如果您不知道,您可能更喜欢 pip),你必须先安装它:

Now you're ready to install numpy and scipy. If you prefer pip to easy_install (if you don't know, you probably prefer pip), you have to install that first:

sudo easy_install-2.6 pip

然后使用它来安装软件包:

Then use it to install the packages:

sudo pip-2.6 install numpy

根据您确切的操作系统版本和其他详细信息,您可能已经内置了 2.6 的 numpy,但该 numpy 不支持 Fortran.你可以这么说是因为 sudo pip-2.6 install numpyRequirement already meet (use --upgrade to upgrade): numpy in/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python.解决方案是完全按照错误消息所说的去做:

Depending on your exact OS version and other details, you may already have a built-in numpy for 2.6, but that numpy doesn't have Fortran support. You can tell this because sudo pip-2.6 install numpy says Requirement already satisfied (use --upgrade to upgrade): numpy in /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python. The solution is to do exactly what the error message says:

sudo pip-2.6 install --upgrade numpy

最后:

sudo pip-2.6 install scipy

这篇关于在 mac OS Lion 上预装 python 2.6.7 的 numpy 和 scipy的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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