繁体   English   中英

在OS X上安装numpy时,pip3找不到Python.h

[英]pip3 cannot find Python.h when installing numpy on OS X

我的操作系统是OSX 10.10.4,我有python2.7.10和python3.5,并尝试为这两个版本的python安装numpy,scipy和matplotlib。

在python2中它运行良好,但对于python3,我尝试使用命令安装numpy

pip3 install numpy

然后事实证明安装终止,因为它找不到文件Python.h但实际上文件python.h确实存在于python3.5的目录中。 所以我现在很困惑。

更新18月9日,确切的错误消息:最初它尝试构建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

然后安装报告了同样的错误。

根据这个页面,这在numpy版本1.9.3中得到修复。 尝试

pip3 install numpy==1.9.3

现在,默认情况下,OSX的Python标头有些混乱/未安装。 你可以运行:

xcode-select --install然后安装命令行工具,它应该工作。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM