14

I want use Twisted in Python, but when I installing ,in comes this error, how to handle it?

....
running build_ext
gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -I/usr/include/python2.7 -c conftest.c -o conftest.o
gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -I/usr/include/python2.7 -c conftest.c -o conftest.o
building 'twisted.runner.portmap' extension
gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -I/usr/include/python2.7 -c twisted/runner/portmap.c -o build/temp.linux-i686-2.7/twisted/runner/portmap.o
twisted/runner/portmap.c:10:20: fatal error: Python.h: No such file or directory
compilation terminated.
error: command 'gcc' failed with exit status 1
zawdd
  • 311
  • 1
  • 3
  • 12
  • possible duplicate of [ubuntu: I have python, but gcc cant find Python.h](http://stackoverflow.com/questions/8282231/ubuntu-i-have-python-but-gcc-cant-find-python-h) – Jean-Paul Calderone Jul 16 '12 at 09:21

1 Answers1

38

You are missing the python development headers, needed to build packages that need to compile extensions.

If you are building on OSX, make sure you either install a prebuilt mac python package or if building python from source, use the framework flag when configuring. And also make sure you have XCODE installed so that you have a compiler.

If you are building on Linux, you probably need to install the python devel headers. For instance on Ubuntu you would need: apt-get install build-essential python-dev. Once you have the python development headers, twisted should be able to find them when you build with that python interpreter.

Glyph
  • 31,152
  • 11
  • 87
  • 129
jdi
  • 90,542
  • 19
  • 167
  • 203
  • I can't test at the moment under Linux, but in Windows the headers are already included in the default python installation. He probably just has to add the include directory correctly. – Voo Jul 15 '12 at 19:40
  • @Voo: The OP does not seem to be using windows. Look at the include path in the commands. I presume it to be linux: `/usr/include/python2.7` – jdi Jul 15 '12 at 19:50
  • I meant: If the headers are included under windows with the default installation, I'd assume that'd also be so under other linux (I'm not sure why exactly the headers are included in the first place, but I'd assume the arguments for including them under windows also hold under *nix). – Voo Jul 15 '12 at 20:30
  • @Voo: It would be different for each platform. Windows does not come with python in the first place, so the installer for windows includes the headers. On OSX, the included python is built as a framework which includes headers for development purposes. On *nix, you usually get a very slim build of python and have to install the development headers separately. – jdi Jul 15 '12 at 20:34
  • 4
    I just dealt with this issue. For anyone using synaptic and python 2.7, the package is specifically called: `python2.7-dev` – Andy Nov 22 '12 at 21:34