python pycrypto 安装错误

12 投票
1 回答
31173 浏览
提问于 2025-04-17 04:44

可能是重复的问题:
在 Mac OS 10.6.3 上找不到 PyCrypto 和 GMP 库的错误

我在 Ubuntu 上尝试安装 pycrypto,但出现了错误

hom@PC71:~/Desktop/pycrypto-2.3$ sudo python setup.py build
running build
running build_py
running build_ext
warning: GMP library not found; Not building Crypto.PublicKey._fastmath.
building 'Crypto.Hash.MD2' extension
gcc -pthread -fno-strict-aliasing -fwrapv -Wall -Wstrict-prototypes -fPIC -std=c99 -O3 -fomit-frame-pointer -Isrc/ -I/usr/include/python2.6 -c src/MD2.c -o build/temp.linux-i686-2.6/src/MD2.o
src/MD2.c:31: fatal error: Python.h: No such file or directory
compilation terminated.
error: command 'gcc' failed with exit status 1

我已经安装了 python-dev 工具。

1 个回答

42

你缺少Python开发所需的库文件。(可以试试用 apt-get install python-dev 来安装。)

不过,除非你有特别的理由想自己编译pycrypto,不然直接用 apt-get install python-crypto 安装就可以了,我觉得这样更简单。

撰写回答