Python.h missing from Ubuntu 12.04
Asked Answered
A

4

68

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?

Astera answered 26/3, 2013 at 6:58 Comment(2)
Location of header files is related to programming, voting for reopen.Saloop
Hit this issue when trying to run my Django code under NGINX. That definitely programming related.Tragedy
H
183

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.

Hightest answered 26/3, 2013 at 7:34 Comment(3)
If you are using another version of Python, 3.3 for example: sudo apt-get install python3.3-devRosamariarosamond
On Ubuntu 14.04, the command 'sudo apt-get install python3' installed the right version without having to specify the version the command line.Tragedy
Hitting the same issue on Centos7.3. Any suggestions?Wildee
I
36

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.

Incognizant answered 26/3, 2013 at 7:11 Comment(0)
L
9

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

Lentic answered 26/3, 2013 at 7:1 Comment(0)
J
0

hey community i solved this problem by this command

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

hope it works :)

Jody answered 14/8, 2020 at 0:14 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.