在 python3.6 上安装 pycrypto

install pycrypto on python3.6

我是 运行 Centos7,Python 3.6。我正在尝试使用命令“pip3 install pycrypto”安装 pycrypto。我还安装了开发工具,因此安装了 gcc。我得到以下输出。 我错过了什么?

    warning: GMP or MPIR library not found; Not building Crypto.PublicKey._fastmath.
    building 'Crypto.Hash._MD2' extension
    creating build/temp.linux-x86_64-3.6
    creating build/temp.linux-x86_64-3.6/src
    gcc -pthread -Wno-unused-result -Wsign-compare -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -fPIC -std=c99 -O3 -fomit-frame-pointer -Isrc/ -I/usr/include/python3.6m -c src/MD2.c -o build/temp.linux-x86_64-3.6/src/MD2.o
    src/MD2.c:31:20: fatal error: Python.h: No such file or directory
     #include "Python.h"
                        ^
    compilation terminated.
    error: command 'gcc' failed with exit status 1
    
    ----------------------------------------
Command "/usr/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-h6pl3s2f/pycrypto/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-9fjag3e5-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-build-h6pl3s2f/pycrypto/

那没有用,但我确实在文章中找到了答案。

I 运行 "yum -y install python3-devel" 这解决了我的问题。然后我能够安装 pycrypto。

我在 CentOS 上也遇到了同样的问题。 但是,事实证明我缺少一个依赖项。

sudo yum install gcc

sudo yum install gcc-c++

sudo yum install python-devel

sudo pip install pycrypto