Cython安装GCC错误

20 投票
2 回答
16388 浏览
提问于 2025-04-16 08:34

我在一个小型的VPS上安装Ubuntu Server,想要安装Cython。于是我执行了

sudo apt-get install gcc

然后又执行了

python setup.py install

在Cython的目录下,但我遇到了一个奇怪的错误。

running install
running build
running build_py
running build_ext
building 'Cython.Plex.Scanners' extension
gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -I/usr/include/python2.6 -c Cython/Plex/Scanners.c -o build/temp.linux-x86_64-2.6/Cython/Plex/Scanners.o
Cython/Plex/Scanners.c:4:20: error: Python.h: No such file or directory
Cython/Plex/Scanners.c:6:6: error: #error Python headers needed to compile C extensions, please install development version of Python.
error: command 'gcc' failed with exit status 1

为什么我需要一个“开发版的Python”?我现在用的是Python 2.6.5(r265:79063,2010年4月16日,13:57:41)。谢谢!

2 个回答

4

你需要在开发版的Python中包含一些头文件,也就是 python.h。在Ubuntu系统中,这个文件应该打包在 python-dev 里。

37

你需要安装开发者版本的Python,也就是需要Python的头文件(Python.h)。

sudo apt-get install python-dev

撰写回答