Python.h missing from Ubuntu 12.04

PythonUbuntu 12.04

Python Problem Overview


I installed an openflow controller on my Ubuntu 12.04 called RYU using:

 sudo  pip install ryu

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

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:

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. The output of python -V however is

Python 2.7.3

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

Python Solutions


Solution 1 - Python

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.

Solution 2 - Python

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.

Solution 3 - Python

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

Solution 4 - Python

hey community i solved this problem by this command

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

hope it works :)

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
Questionliv2hakView Question on Stackoverflow
Solution 1 - Pythonuser2173955View Answer on Stackoverflow
Solution 2 - PythonNPEView Answer on Stackoverflow
Solution 3 - PythonBurhan KhalidView Answer on Stackoverflow
Solution 4 - PythonBa ZookaView Answer on Stackoverflow