Gangmax Blog

Resolve Python "pycrypto" installation error

When I try installing “paramiko” on my local “Python3” environment with “pip”, the depended package “pycrypto” installation reports the following error:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
    checking for memmove... yes
checking for memset... yes
configure: creating ./config.status
config.status: creating src/config.h
building 'Crypto.Hash._MD2' extension
creating build/temp.linux-x86_64-3.4
creating build/temp.linux-x86_64-3.4/src
x86_64-linux-gnu-gcc -pthread -fwrapv -Wall -Wstrict-prototypes -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -D_FORTIFY_SOURCE=2 -fPIC -std=c99 -O3 -fomit-frame-pointer -Isrc/ -I/usr/include/python3.4m -I/home/user/lang/python/python3/include/python3.4m -c src/MD2.c -o build/temp.linux-x86_64-3.4/src/MD2.o
src/MD2.c:31:20: fatal error: Python.h: No such file or directory
#include "Python.h"
^
compilation terminated.
warning: GMP or MPIR library not found; Not building Crypto.PublicKey._fastmath.
error: command 'x86_64-linux-gnu-gcc' failed with exit status 1

----------------------------------------
Command "/home/user/lang/python/python3/bin/python3 -c "import setuptools, tokenize;__file__='/tmp/pip-build-_rny99e_/pycrypto/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-kl1nrukq-record/install-record.txt --single-version-externally-managed --compile --install-headers /home/user/lang/python/python3/include/site/python3.4/pycrypto" failed with error code 1 in /tmp/pip-build-_rny99e_/pycrypto

However when I did the same thing on my local Python2 environment it did not happened. It seems the root cause is that the “python.h” file of Python3 cannot be found. So I did:

1
2
3
4
apt-cache search python3-dev
sudo apt-get install python3-dev
pip install pycrypto
pip install paramiko

It works.

Comments