17

I tried to install twisted on Linux from source code on my Linux sever. When I use this command setup.py install, it failed with a error message below:

twisted/runner/portmap.c:10:20: error: Python.h: No such file or directory
twisted/runner/portmap.c:14: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token
twisted/runner/portmap.c:31: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token
twisted/runner/portmap.c:45: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘PortmapMethods’
twisted/runner/portmap.c: In function ‘initportmap’:
twisted/runner/portmap.c:55: warning: implicit declaration of function ‘Py_InitModule’
twisted/runner/portmap.c:55: error: ‘PortmapMethods’ undeclared (first use in this function)
twisted/runner/portmap.c:55: error: (Each undeclared identifier is reported only once
twisted/runner/portmap.c:55: error: for each function it appears in.)
error: command 'gcc' failed with exit status 1

BTW, I don't have root permission on that machine, and Python is installed in my home folder, not /usr/bin

TheCodeArtist
  • 21,479
  • 4
  • 69
  • 130
user694163
  • 577
  • 2
  • 5
  • 10
  • 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 Dec 31 '11 at 20:13

1 Answers1

42

The compiler can't find python development headers. Asking the system administrator to install python-devel in case of CentOS or to install python-dev on Debian, Ubuntu and their derivatives. That should help.

Tim McNamara
  • 18,019
  • 4
  • 52
  • 83
Pavel Shvedov
  • 1,284
  • 11
  • 8