2011-10-21 208 views
12

可能重複:
PyCrypto and GMP library not found error [Mac OS 10.6.3]蟒蛇pycrypto安裝錯誤

我嘗試Ubuntu上安裝pycrypto,但它會拋出錯誤

[email protected]:~/Desktop/pycrypto-2.3$ sudo python setup.py build 
running build 
running build_py 
running build_ext 
warning: GMP 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.6 -c src/MD2.c -o build/temp.linux-i686-2.6/src/MD2.o 
src/MD2.c:31: fatal error: Python.h: No such file or directory 
compilation terminated. 
error: command 'gcc' failed with exit status 1 

我已經安裝了Python -dev工具已經。

回答

42

您錯過了Python開發庫。 (嘗試apt-get install python-dev。)

但是,除非你有自己的編譯pycrypto的正當理由,只需通過(我認爲)安裝它apt-get install python-crypto

+0

在linux上運行:如果你已經安裝了GMP,但是沒有安裝pycrypto,你需要安裝它們,pycrypto – Ross

+1

「apt-get install python-crypto」在我的Raspberry Pi上爲我工作,謝謝! – armani

+2

這解決了我在安裝通過pip升級Ansible所必需的依賴關係時遇到的問題:'sudo pip install ansible --upgrade'(其中之一是pycrypto) –