在python中安装Twisted失败并显示'No such file'

zaw*_*wdd 14 python linux twisted

我想在Python中使用Twisted,但是当我安装时,出现此错误,如何处理它?

....
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
Run Code Online (Sandbox Code Playgroud)

jdi*_*jdi 38

您缺少构建需要编译扩展的包所需的python开发头.

如果您在OSX上构建,请确保安装预构建的mac python包或者如果从源代码构建python,请在配置时使用framework标志.并确保安装了XCODE,以便拥有编译器.

如果您在Linux上构建,则可能需要安装python devel头文件.例如在Ubuntu上你需要: apt-get install build-essential python-dev.一旦你有了python开发头文件,在使用那个python解释器构建时,twisted应该能够找到它们.

  • 我刚刚处理了这个问题.对于任何使用synaptic和python 2.7的人来说,这个包都是专门叫做的:`python2.7-dev` (4认同)