easy_install找不到Python.h

时间:2015-03-11 16:05:52

标签: python gcc easy-install

我试图使用easy_install在Suse linux上安装pyyaml。我得到以下输出:

sudo easy_install pyyaml
root's password:
Searching for pyyaml
Reading https://pypi.python.org/simple/pyyaml/
Best match: PyYAML 3.11
Downloading https://pypi.python.org/packages/source/P/PyYAML/PyYAML-3.11.zip#md5=89cbc92cda979042533b640b76e6e055
Processing PyYAML-3.11.zip
Writing /tmp/easy_install-51ghymsa/PyYAML-3.11/setup.cfg
Running PyYAML-3.11/setup.py -q bdist_egg --dist-dir /tmp/easy_install-51ghymsa/PyYAML-3.11/egg-dist-tmp-3neiipqa
ext/_yaml.c:16:20: fatal error: Python.h: No such file or directory
#include "Python.h"
                    ^
compilation terminated.
error: Setup script exited with error: command 'gcc' failed with exit status 1

我安装了python-devel,"找到了Python.h"给出" /usr/include/python2.7/Python.h"。我无法找到如何让easy_install看到它。我很感激你的帮助!

更新:尝试使用pip而不是easy_install进行安装,我看到gcc使用了错误的include-dirs:/usr/include/python3.4m而不是/usr/include/python2.7。我试过跑

sudo pip install --global-option=build_ext --global-option="-I/usr/include/python2.7" pyyaml

但是这只是让gcc运行时将include dirs设置为两者 python2.7和3.4m,这会产生自己的问题。将CPLUS_INCLUDE_PATH和C_INCLUDE_PATH设置为/usr/include/python2.7似乎没有任何区别。

1 个答案:

答案 0 :(得分:0)

首先安装python3-devel怎么样?

$ sudo zypper install python3-devel 

希望它有所帮助。