phicdy devlog

Androidアプリ開発やその他技術系の記事をたまに書きます

AndroidとかiOSとかモバイル多め。その他技術的なことも書いていきます。

pycryptoのインストールがCentOS7.3 minimalで失敗する問題の対処

環境

[root@localhost ~]# cat /etc/redhat-release
CentOS Linux release 7.3.1611 (Core)

結論

gccpython-develをyumで入れる

調査

デフォルトで入れようとすると以下ログでこける。Cコンパイラがないとのことなのでgccを入れる

[root@localhost ~]# pip install pycrypto
...
    configure: error: in `/tmp/pip-build-EJivFC/pycrypto':
    configure: error: no acceptable C compiler found in $PATH
    See `config.log' for more details
...
Command "/usr/bin/python2 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-EJivFC/pycrypto/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().re
place('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-WsN8Es-record/install-record.txt --single-version-externally-managed --compil
e" failed with error code 1 in /tmp/pip-build-EJivFC/pycrypto/
[root@localhost ~]# yum install gcc

もう1回実行するとPython.hがないと言われる。調べた結果これはpython-develがないためとのことなので入れて解決。

...
    gcc -pthread -fno-strict-aliasing -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 -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/python2.7 -c src/MD2.c -o build/temp.linux-x86_64-2.7/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/python2 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-2l6kpU/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-7LFD3X-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-build-2l6kpU/pycrypto/
[root@localhost ~]# yum install python-devel