【发布时间】:2015-09-17 16:38:26
【问题描述】:
我的操作系统是 OSX 10.10.4,我同时拥有 python2.7.10 和 python3.5,并尝试为这两个版本的 python 安装 numpy、scipy 和 matplotlib。
在 python2 中运行良好,但对于 python3,我尝试使用命令安装 numpy
pip3 install numpy
后来发现安装终止是因为找不到文件Python.h 但实际上python3.5的目录下确实存在python.h文件。所以我现在很困惑。
9 月 18 日更新,确切的错误消息: 最初它试图构建 numpy:
compile options: '-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 -c'
clang: _configtest.c
_configtest.c:1:10: fatal error: 'Python.h' file not found
#include <Python.h>
^
1 error generated.
_configtest.c:1:10: fatal error: 'Python.h' file not found
#include <Python.h>
^
1 error generated.
failure.
removing: _configtest.c _configtest.o
Running from numpy source directory.
/usr/local/Cellar/python3/3.5.0/Frameworks/Python.framework/Versions/3.5/lib/python3.5/distutils/dist.py:261: UserWarning: Unknown distribution option: 'define_macros'
warnings.warn(msg)
.....
File "numpy/core/setup.py", line 293, in check_types
"Cannot compile 'Python.h'. Perhaps you need to "\
SystemError: Cannot compile 'Python.h'. Perhaps you need to install python-dev|python-devel.
----------------------------------------
Failed building wheel for numpy
Failed to build numpy
然后安装报同样的错误。
【问题讨论】:
-
发布确切的错误信息。
-
我遇到了同样的问题。您是否使用 Homebrew 安装了 Python3?您的 Homebrew 是否处于非标准路径?
-
最后我关注了 miniconda,现在一切运行良好
-
您能否发布您的解决方案作为答案。 @BernardYuan
-
当然,我按照中文教程告诉你如何在OS X上设置科学计算环境,我会简要写下主要思想并在我的期末考试后发布:) @sirvon