致命错误:Python.h 没有这样的文件或目录

致命错误:Python.h 没有这样的文件或目录
root@rani-System-Product-Name:~# sudo pip install python-igraph
Downloading/unpacking python-igraph
  Downloading python-igraph-0.7.1.post6.tar.gz (377Kb): 377Kb downloaded
  Running setup.py egg_info for package python-igraph

Installing collected packages: python-igraph
  Running setup.py install for python-igraph
    Build type: dynamic extension
    Include path:
    Library path:
    Runtime library path:
    Linked dynamic libraries: igraph
    Linked static libraries:
    Extra compiler options:
    Extra linker options:
    building 'igraph._igraph' extension
    gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -I/usr/include/python2.7 -c src/arpackobject.c -o build/temp.linux-i686-2.7/src/arpackobject.o
    In file included from src/arpackobject.c:23:0:
    src/arpackobject.h:26:20: fatal error: Python.h: No such file or directory
    compilation terminated.
    error: command 'gcc' failed with exit status 1
    Complete output from command /usr/bin/python -c "import setuptools;__file__='/root/build/python-igraph/setup.py';exec(compile(open(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --single-version-externally-managed --record /tmp/pip-qMvawh-record/install-record.txt:
    running install

running build

running build_py

creating build

creating build/lib.linux-i686-2.7

creating build/lib.linux-i686-2.7/igraph

copying igraph/__init__.py -> build/lib.linux-i686-2.7/igraph

copying igraph/summary.py -> build/lib.linux-i686-2.7/igraph

copying igraph/utils.py -> build/lib.linux-i686-2.7/igraph

copying igraph/datatypes.py -> build/lib.linux-i686-2.7/igraph

copying igraph/statistics.py -> build/lib.linux-i686-2.7/igraph

copying igraph/compat.py -> build/lib.linux-i686-2.7/igraph

copying igraph/configuration.py -> build/lib.linux-i686-2.7/igraph

copying igraph/matching.py -> build/lib.linux-i686-2.7/igraph

copying igraph/layout.py -> build/lib.linux-i686-2.7/igraph

copying igraph/clustering.py -> build/lib.linux-i686-2.7/igraph

copying igraph/cut.py -> build/lib.linux-i686-2.7/igraph

copying igraph/formula.py -> build/lib.linux-i686-2.7/igraph

creating build/lib.linux-i686-2.7/igraph/test

copying igraph/test/basic.py -> build/lib.linux-i686-2.7/igraph/test

copying igraph/test/__init__.py -> build/lib.linux-i686-2.7/igraph/test

copying igraph/test/vertexseq.py -> build/lib.linux-i686-2.7/igraph/test

copying igraph/test/decomposition.py -> build/lib.linux-i686-2.7/igraph/test

copying igraph/test/indexing.py -> build/lib.linux-i686-2.7/igraph/test

copying igraph/test/utils.py -> build/lib.linux-i686-2.7/igraph/test

copying igraph/test/edgeseq.py -> build/lib.linux-i686-2.7/igraph/test

copying igraph/test/cliques.py -> build/lib.linux-i686-2.7/igraph/test

copying igraph/test/generators.py -> build/lib.linux-i686-2.7/igraph/test

copying igraph/test/atlas.py -> build/lib.linux-i686-2.7/igraph/test

copying igraph/test/flow.py -> build/lib.linux-i686-2.7/igraph/test

copying igraph/test/iterators.py -> build/lib.linux-i686-2.7/igraph/test

copying igraph/test/homepage.py -> build/lib.linux-i686-2.7/igraph/test

copying igraph/test/isomorphism.py -> build/lib.linux-i686-2.7/igraph/test

copying igraph/test/rng.py -> build/lib.linux-i686-2.7/igraph/test

copying igraph/test/matching.py -> build/lib.linux-i686-2.7/igraph/test

copying igraph/test/structural.py -> build/lib.linux-i686-2.7/igraph/test

copying igraph/test/separators.py -> build/lib.linux-i686-2.7/igraph/test

copying igraph/test/operators.py -> build/lib.linux-i686-2.7/igraph/test

copying igraph/test/spectral.py -> build/lib.linux-i686-2.7/igraph/test

copying igraph/test/games.py -> build/lib.linux-i686-2.7/igraph/test

copying igraph/test/conversion.py -> build/lib.linux-i686-2.7/igraph/test

copying igraph/test/layouts.py -> build/lib.linux-i686-2.7/igraph/test

copying igraph/test/foreign.py -> build/lib.linux-i686-2.7/igraph/test

copying igraph/test/attributes.py -> build/lib.linux-i686-2.7/igraph/test

copying igraph/test/colortests.py -> build/lib.linux-i686-2.7/igraph/test

copying igraph/test/bipartite.py -> build/lib.linux-i686-2.7/igraph/test

creating build/lib.linux-i686-2.7/igraph/app

copying igraph/app/__init__.py -> build/lib.linux-i686-2.7/igraph/app

copying igraph/app/shell.py -> build/lib.linux-i686-2.7/igraph/app

creating build/lib.linux-i686-2.7/igraph/drawing

copying igraph/drawing/text.py -> build/lib.linux-i686-2.7/igraph/drawing

copying igraph/drawing/baseclasses.py -> build/lib.linux-i686-2.7/igraph/drawing

copying igraph/drawing/__init__.py -> build/lib.linux-i686-2.7/igraph/drawing

copying igraph/drawing/shapes.py -> build/lib.linux-i686-2.7/igraph/drawing

copying igraph/drawing/utils.py -> build/lib.linux-i686-2.7/igraph/drawing

copying igraph/drawing/graph.py -> build/lib.linux-i686-2.7/igraph/drawing

copying igraph/drawing/metamagic.py -> build/lib.linux-i686-2.7/igraph/drawing

copying igraph/drawing/colors.py -> build/lib.linux-i686-2.7/igraph/drawing

copying igraph/drawing/vertex.py -> build/lib.linux-i686-2.7/igraph/drawing

copying igraph/drawing/coord.py -> build/lib.linux-i686-2.7/igraph/drawing

copying igraph/drawing/edge.py -> build/lib.linux-i686-2.7/igraph/drawing

creating build/lib.linux-i686-2.7/igraph/remote

copying igraph/remote/__init__.py -> build/lib.linux-i686-2.7/igraph/remote

copying igraph/remote/nexus.py -> build/lib.linux-i686-2.7/igraph/remote

copying igraph/remote/gephi.py -> build/lib.linux-i686-2.7/igraph/remote

creating build/lib.linux-i686-2.7/igraph/vendor

copying igraph/vendor/__init__.py -> build/lib.linux-i686-2.7/igraph/vendor

copying igraph/vendor/texttable.py -> build/lib.linux-i686-2.7/igraph/vendor

running build_ext

Build type: dynamic extension

Include path:

Library path:

Runtime library path:

Linked dynamic libraries: igraph

Linked static libraries:

Extra compiler options:

Extra linker options:

building 'igraph._igraph' extension

creating build/temp.linux-i686-2.7

creating build/temp.linux-i686-2.7/src

gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -I/usr/include/python2.7 -c src/arpackobject.c -o build/temp.linux-i686-2.7/src/arpackobject.o

In file included from src/arpackobject.c:23:0:

src/arpackobject.h:26:20: fatal error: Python.h: No such file or directory

compilation terminated.

error: command 'gcc' failed with exit status 1

----------------------------------------
Command /usr/bin/python -c "import setuptools;__file__='/root/build/python-igraph/setup.py';exec(compile(open(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --single-version-externally-managed --record /tmp/pip-qMvawh-record/install-record.txt failed with error code 1
Storing complete log in /root/.pip/pip.log

当我在命令行上输入 python 时,它给出的结果如下

root@rani-System-Product-Name:~# python
Python 2.7.5 (default, Jun 29 2015, 10:00:26) 
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> 

帮我。

答案1

通用答案(不关注 12.04):您缺少“Python 头文件”,而这些文件位于其中 1 个里面......

sudo apt-get install python-dev
sudo apt-get install python-devel
sudo apt-get install python2.7-dev

或者你可以安装所有可用的

sudo apt-get install python-all-dev

输入python --version以查看您所使用的 python 版本。

更具体:由于您使用的是 12.04,我假设您只需要python2.7-dev

相关内容