xcode 在 Mac OS X Lion 10.7 上安装 Numpy

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/7338051/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-09 04:05:35  来源:igfitidea点击:

Install Numpy on Mac OS X Lion 10.7

xcodemacosnumpyinstall

提问by Jensen

I need to install Numpy on my Mac OS X Lion 10.7. I googled a little bit, it seems like there are a lot of stuff needs to be installed. And some says I need install Xcode before I install Numpy. But the official website of Numpy doesn't give much information about installing Numpy on Mac. I really don't want to install Xcode as it would cost a lot space.

我需要在我的 Mac OS X Lion 10.7 上安装 Numpy。我用谷歌搜索了一下,似乎有很多东西需要安装。有人说我需要在安装 Numpy 之前安装 Xcode。但是Numpy的官网并没有提供太多关于在Mac上安装Numpy的信息。我真的不想安装 Xcode,因为它会花费很多空间。

So anyone knows how to install Numpy? What's the prerequisites?

那么有人知道如何安装Numpy吗?先决条件是什么?

Thanks,

谢谢,

采纳答案by jjh

Generally, unless you have a good reason you might want to avoid trying to have to build numpy/scipy et al. yourself.

通常,除非您有充分的理由,否则您可能希望避免尝试构建 numpy/scipy 等。你自己。

For Mac's there are two nice everything-included packages for numerical python. Enthough distribution (paid, http://www.enthought.com/) and Sagemath (free, http://www.sagemath.org/). I'm happily using Sagemath on 10.7 - it has numpy, scipy etc.

对于 Mac,有两个很好的包含所有内容的数字 Python 软件包。Enthough 分发(付费,http://www.enthought.com/)和 Sagemath(免费,http://www.sagemath.org/)。我很高兴在 10.7 上使用 Sagemath - 它有 numpy、scipy 等。

回答by Ingmar Hupp

Lion comes with numpy installed. It should already be there:

Lion 安装了 numpy。它应该已经在那里了:

$ python -c 'import numpy, numpy.version; print numpy, numpy.version.version'
<module 'numpy' from '/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/numpy/__init__.py'> 1.5.1

回答by dlamotte

For anyone that hits this from google, here is where I figured out how to build numpy on Mac OS.

对于从 google 找到这个的任何人,这里是我想出如何在 Mac OS 上构建 numpy 的地方。

http://www.scipy.org/Installing_SciPy/Mac_OS_X

http://www.scipy.org/Installing_SciPy/Mac_OS_X

On lion, it amounts to setting some environment variables (after Xcode is installed):

在 Lion 上,它相当于设置一些环境变量(安装 Xcode 后):

export CC=gcc-4.2
export CXX=g++-4.2
export FFLAGS=-ff2c

Then pip install numpyworks just fine.

然后pip install numpy工作得很好。

回答by El Developer

I have used a few software packages that require a fresh install of NumPy, that won't work with the built in NumPy or even with the built-in Python. The easiest way to install NumPy on the mac is to download any of these packages. This will work for most OS versions.

我使用了一些需要全新安装 NumPy 的软件包,这些软件包不适用于内置的 NumPy 甚至内置的 Python。在 Mac 上安装 NumPy 的最简单方法是下载这些软件包中的任何一个。这适用于大多数操作系统版本。

Still the other answers are valid, though this is a more general answer.

其他答案仍然有效,尽管这是一个更一般的答案。

This is the SourceForgepage of the project.

这是项目的SourceForge页面。

回答by Nick

If you do install Xcode you can get the latest and greatest open source libraries and packages. Consider using the excellent Mac Ports (http://www.macports.org) project. It is a package manager that will download source packages and their dependencies and build all the libraries and tools for you.

如果你安装了 Xcode,你可以获得最新最好的开源库和包。考虑使用优秀的 Mac Ports (http://www.macports.org) 项目。它是一个包管理器,它将下载源包及其依赖项并为您构建所有库和工具。

Installing Numpy becomes a one line command once Xcode and mac ports is installed:

一旦安装了 Xcode 和 mac 端口,安装 Numpy 就变成了一个单行命令:

sudo port install py27-numpy

sudo port install py27-numpy

回答by Brideau

The easiest way that I found was to visit http://sourceforge.net/projects/numpy/files/NumPy/, pick the folder of the latest version, and then download the .dmg file that matched my installed version of Python.

我发现的最简单的方法是访问http://sourceforge.net/projects/numpy/files/NumPy/,选择最新版本的文件夹,然后下载与我安装的 Python 版本匹配的 .dmg 文件。

回答by Brian B

Based on this post, I found that Chris Fonnesbeck keeps a highly functional installer script for OSX 10.7 at the OSX SuperPack Github site.

基于这篇博文,我发现 Chris Fonnesbeck 在OSX SuperPack Github 站点上为 OSX 10.7 保留了一个功能强大的安装程序脚本。

Because I hapened to have all the dependencies (such as gfortran) already, I did not use his full shell script. Rather I just did

因为我已经拥有了所有的依赖项(例如 gfortran),所以我没有使用他的完整 shell 脚本。相反,我只是做了

git clone --depth=1 git://github.com/fonnesbeck/ScipySuperpack.git  
python -m easy_install -N -Z ScipySuperpack/*.egg   

And it worked beautifully. In particular, it worked better than the .dmgfiles from the official numpy and scipy distributions, and better than pip install.

它工作得很好。特别是,它比.dmg官方 numpy 和 scipy 发行版中的文件运行得更好,并且比pip install.

回答by Ashkan

You can install numpy/scipy using pip, If pip is not installed on your machine, you can install it with easy_install:

您可以使用 pip 安装 numpy/scipy,如果您的机器上没有安装 pip,您可以使用 easy_install 安装它:

sudo easy_install pip

Then install numpy:

然后安装numpy:

sudo pip install numpy

回答by arokem

A very easy route is to install Anacondafrom Continuum, or Enthought's Canopy. These are python distributions that include numpy, as well as other useful scientific computing libraries

一个非常简单的方法是从 Continuum 或 Enthought 的Canopy安装Anaconda。这些是 Python 发行版,包括以及其他有用的科学计算库numpy