Ubuntu 12.04 中缺少 Python.h

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/15631135/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-18 20:34:56  来源:igfitidea点击:

Python.h missing from Ubuntu 12.04

pythonubuntu-12.04

提问by liv2hak

I am very new to python.I installed an openflow controller on my Linux PC (Ubunutu 12.04) called RYU using:

我对 python 非常陌生。我在我的 Linux PC(Ubunutu 12.04)上安装了一个名为 RYU 的 openflow 控制器,使用:

 sudo  pip install ryu

I was trying to run a python file using ryu-manager as shown below.

我试图使用 ryu-manager 运行一个 python 文件,如下所示。

sudo ryu-manager simple_switch.py 
Traceback (most recent call last):
  File "/usr/local/bin/ryu-manager", line 19, in <module>
    import gevent
ImportError: No module named gevent

Then I tried to install gevent using:

然后我尝试使用以下方法安装 gevent:

sudo pip install gevent
gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -I/usr/include/python2.7 -c gevent/core.c -o build/temp.linux-x86_64-2.7/gevent/core.o
gevent/core.c:4:20: fatal error: Python.h: No such file or directory

compilation terminated.

error: command 'gcc' failed with exit status 1

What is the cause of this error? I tried to locate the Python.h file using:

这个错误的原因是什么?我尝试使用以下方法定位 Python.h 文件:

  sudo locate Python.h

I couldn't find it on my system.However if I run:

我在我的系统上找不到它。但是,如果我运行:

python -V

I get the output:

我得到输出:

Python 2.7.3

Should Python.h be there on the system? If so, what should I install to get it?

系统上应该有 Python.h 吗?如果是这样,我应该安装什么才能得到它?

采纳答案by NPE

This should do it:

这应该这样做:

sudo apt-get update; sudo apt-get install python-dev -y

sudo apt-get update; sudo apt-get install python-dev -y

It will install any missing headers. It helped me a lot.

它将安装任何丢失的标头。这对我帮助很大。

回答by Burhan Khalid

Install geventdirectly - sudo apt-get install python-gevent.

gevent直接安装- sudo apt-get install python-gevent.

回答by NPE

Even if you have Python installed, the header file and the library usually aren't installed by default. On Ubuntu, they come in a separate package called python-dev.

即使您安装了 Python,默认情况下通常也不会安装头文件和库。在 Ubuntu 上,它们包含在一个名为python-dev.