Python.h missing from Ubuntu 12.04

不羁的心 提交于 2019-11-26 19:21:51

问题


I am very new to python.I installed an openflow controller on my Linux PC (Ubunutu 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 the Python.h file using:

  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?


回答1:


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.




回答2:


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.




回答3:


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



来源:https://stackoverflow.com/questions/15631135/python-h-missing-from-ubuntu-12-04

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!