简体   繁体   English

在 Ubuntu 上安装 PyCrypto - 构建时出现致命错误

[英]Installing PyCrypto on Ubuntu - fatal error on build

Having looked at other similar threads, I still can't get pycrypto running.查看了其他类似的线程后,我仍然无法运行 pycrypto。

I'm trying to get it working on my Ubuntu laptop - but I couldn't manage it on my Windows PC either.我试图让它在我的 Ubuntu 笔记本电脑上运行 - 但我也无法在我的 Windows PC 上管理它。

I downloaded pycrypto-2.6, extracted it, and ran我下载了 pycrypto-2.6,解压并运行

    python setup.py build

but then this happened但后来这件事发生了

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

Would appreciate any help.将不胜感激任何帮助。

You need to install the Python development files. 您需要安装Python开发文件。 I believe this will do it: 我相信这样做会:

sudo apt-get install python-dev

On Ubuntu, I needed some other packages for it to succeed: 在Ubuntu上,我需要一些其他的包才能成功:

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

On Ubuntu and if you use Python 3.x you will need: 在Ubuntu上,如果你使用Python 3.x,你将需要:

sudo apt-get install gcc python3-dev

you probably already have gcc but just in case if you are trying this command from Dockerfile with base image python:3.6.4-slim-jessie then you will also need gcc. 你可能已经有了gcc,但万一你要从Dockerfile尝试这个命令与基本图像python:3.6.4-slim-jessie然后你还需要gcc。

August 2021 2021 年 8 月

For python 3.8 users run对于 python 3.8 用户运行

sudo apt-get install python3.8-dev

and try to install pycrypto again并再次尝试安装 pycrypto

pip install pycrypto

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM