1. 程式人生 > >Python 安裝模組錯誤 error: command 'gcc' failed with exit status 1

Python 安裝模組錯誤 error: command 'gcc' failed with exit status 1

環境:linux

命令:

pip install pycrypto

錯誤:

    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

解決方案:

Try:

apt-get install python-dev

That should do the trick. You can also download it from here.

EDIT

try the following:

apt-get install python-devel
or
apt-get install python2.7-dev

centos 用yum

解決後:

Collecting pycrypto
  Using cached https://files.pythonhosted.org/packages/60/db/645aa9af249f059cc3a368b118de33889219e0362141e75d4eaf6f80f163/pycrypto-2.6.1.tar.gz
Installing collected packages: pycrypto
  Running setup.py install for pycrypto ... done
Successfully installed pycrypto-2.6.1

源自:https://stackoverflow.com/questions/13720578/python-module-installation-error-command-gcc-failed-with-exit-status-1