无法在OS X Yosemite上安装numpy

3

我在升级到OS X Yosemite之后无法使用pip install pandaspip install numpy。这两个命令以前都可以正常工作。当我运行

$ pip install numpy

编译过程运行约30秒,然后出现以下内容:

正在编译C源代码

C compiler: cc -DNDEBUG -g -fwrapv -Os -Wall -Wstrict-prototypes -Qunused-arguments -Qunused-arguments -arch x86_64 -arch i386 -pipe



creating build/temp.macosx-10.10-intel-2.7/numpy/linalg

creating build/temp.macosx-10.10-intel-2.7/numpy/linalg/lapack_lite

compile options: '-DATLAS_INFO="\"3.9.35\"" -I/opt/local/include -Inumpy/core/include -Ibuild/src.macosx-10.10-intel-2.7/numpy/core/include/numpy -Inumpy/core/src/private -Inumpy/core/src -Inumpy/core -Inumpy/core/src/npymath -Inumpy/core/src/multiarray -Inumpy/core/src/umath -Inumpy/core/src/npysort -Inumpy/core/include -I/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -Ibuild/src.macosx-10.10-intel-2.7/numpy/core/src/private -Ibuild/src.macosx-10.10-intel-2.7/numpy/core/src/private -Ibuild/src.macosx-10.10-intel-2.7/numpy/core/src/private -Ibuild/src.macosx-10.10-intel-2.7/numpy/core/src/private -c'

cc: numpy/linalg/lapack_lite/python_xerbla.c

cc: numpy/linalg/lapack_litemodule.c

/usr/local/bin/gfortran -Wall -g -arch x86_64 -Wall -g -undefined dynamic_lookup -bundle build/temp.macosx-10.10-intel-2.7/numpy/linalg/lapack_litemodule.o build/temp.macosx-10.10-intel-2.7/numpy/linalg/lapack_lite/python_xerbla.o -L/opt/local/lib -L/usr/local/Cellar/gcc/4.9.1/lib/gcc/x86_64-apple-darwin14.0.0/4.9.1 -Lbuild/temp.macosx-10.10-intel-2.7 -llapack -lptf77blas -lptcblas -latlas -lgfortran -o build/lib.macosx-10.10-intel-2.7/numpy/linalg/lapack_lite.so

ld: symbol dyld_stub_binding_helper not found, normally in crt1.o/dylib1.o/bundle1.o for architecture x86_64

collect2: error: ld returned 1 exit status

ld: symbol dyld_stub_binding_helper not found, normally in crt1.o/dylib1.o/bundle1.o for architecture x86_64

collect2: error: ld returned 1 exit status

error: Command "/usr/local/bin/gfortran -Wall -g -arch x86_64 -Wall -g -undefined dynamic_lookup -bundle build/temp.macosx-10.10-intel-2.7/numpy/linalg/lapack_litemodule.o build/temp.macosx-10.10-intel-2.7/numpy/linalg/lapack_lite/python_xerbla.o -L/opt/local/lib -L/usr/local/Cellar/gcc/4.9.1/lib/gcc/x86_64-apple-darwin14.0.0/4.9.1 -Lbuild/temp.macosx-10.10-intel-2.7 -llapack -lptf77blas -lptcblas -latlas -lgfortran -o build/lib.macosx-10.10-intel-2.7/numpy/linalg/lapack_lite.so" failed with exit status 1

----------------------------------------
Cleaning up...
Command /Users/admin/.virtualenvs/numpy_env/bin/python -c "import setuptools, tokenize;__file__='/Users/admin/.virtualenvs/numpy_env/build/numpy/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /var/folders/5b/1l8zg39d48d865bktn00qnbr0000gn/T/pip-yQOlkU-record/install-record.txt --single-version-externally-managed --compile --install-headers /Users/admin/.virtualenvs/numpy_env/include/site/python2.7 failed with error code 1 in /Users/admin/.virtualenvs/numpy_env/build/numpy
Storing debug log for failure in /var/folders/5b/1l8zg39d48d865bktn00qnbr0000gn/T/tmpuDgjp9

我尝试过升级Python、重新创建虚拟环境、重启系统以及在桌子上摔头,但这些都没有帮助。我还运行了brew rm gfortran,然后是brew install gcc,但这也没有帮助。


我不确定背后的真正问题是什么,但您是否可以安装Anaconda发行版呢?我的经验是,无论操作系统如何,他们的发行版几乎总是保证能够正常工作SciPy堆栈。 - ericmjl
@ericmjl Anaconda很好,但它不能解决那些想要从源代码构建的人们的同样问题,例如开发分支在发布拉取请求之前测试错误修复。 - ogrisel
在OSX 10.9上,pip install numpy也使用二进制轮包,因此不需要构建步骤。但是,在10.10上由于pip的严格平台标签检查和发布在https://pypi.python.org/pypi/numpy/1.8.1上的macosx轮包文件名,这种方法无法工作。未来版本的pip可能会修复这个问题,并允许在OSX平台标签中进行向前兼容。 - ogrisel
Tim:你应该在冷却期后将你的更新作为答案并标记为有效(绿色勾)。 - ogrisel
1个回答

2
根据 Twitter 上某人的建议,我运行了 brew uninstall gcc 命令。这导致 numpy 安装使用 XCode 提供的 gcc,看起来效果很好。
Homebrew 安装的是 gc 4.9,而 Apple 的版本是 4.2.1。然而,我不知道其中的潜在问题是什么。

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接