在Ubuntu上安装PyCrypto - 构建时发生致命错误

时间:2012-07-22 00:17:38

标签: python pycrypto

看过其他类似的线程后,我仍然无法运行pycrypto。

我正在努力让它在我的Ubuntu笔记本电脑上运行 - 但我无法在我的Windows PC上管理它。

我下载了pycrypto-2.6,将其解压缩并运行

    python setup.py build

然后发生了这件事

warning: GMP or MPIR 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.7 -c src/MD2.c -o build/temp.linux-i686-?2.7/src/MD2.o
src/MD2.c:31:20: fatal error: Python.h: No such file or directory
compilation terminated.
error: command 'gcc' failed with exit status 1

感谢任何帮助。

4 个答案:

答案 0 :(得分:143)

您需要安装Python开发文件。我相信这样做会:

sudo apt-get install python-dev

答案 1 :(得分:20)

在Ubuntu上,我需要一些其他的包才能成功:

apt-get install autoconf g++ python2.7-dev
pip install pycrypto

答案 2 :(得分:5)

在Ubuntu上,如果使用Python 3.x,则需要:

sudo apt-get install gcc python3-dev

你可能已经拥有了gcc,但万一你要使用基本图片python从Dockerfile尝试这个命令:3.6.4-slim-jessie那么你还需要gcc。

答案 3 :(得分:0)

2021 年 8 月

对于 python 3.8 用户运行

sudo apt-get install python3.8-dev

并再次尝试安装 pycrypto

pip install pycrypto
相关问题