简体   繁体   English

Ubuntu 12.04 中缺少 Python.h

[英]Python.h missing from Ubuntu 12.04

I installed an openflow controller on my Ubuntu 12.04 called RYU using:我使用以下命令在我的 Ubuntu 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 Python.h using sudo locate Python.h , but without success.我尝试使用sudo locate Python.h locate Python.hsudo locate Python.h ,但没有成功。 The output of python -V however is然而python -V的输出是

Python 2.7.3

Should Python.h be there on the system?系统上应该有Python.h吗? If so, what should I install to get it?如果是这样,我应该安装什么才能得到它?

This should do it:这应该这样做:

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

It will install any missing headers.它将安装任何丢失的标头。 It helped me a lot.这对我帮助很大。

Even if you have Python installed, the header file and the library usually aren't installed by default.即使您安装了 Python,默认情况下通常也不会安装头文件和库。 On Ubuntu, they come in a separate package called python-dev .在 Ubuntu 上,它们包含在一个名为python-dev的单独包中。

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

hey community i solved this problem by this command嘿社区我通过这个命令解决了这个问题

pip3 install -U git+https://github.com/kti/python-netfilterqueue pip3 install -U git+https://github.com/kti/python-netfilterqueue

hope it works :)希望它有效:)

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

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