2013-03-13 14 views
21

Sembra che ci siano un numero di persone che hanno avuto un problema simile, tuttavia, dopo molte ricerche non sono stato in grado di trovare una soluzione che funzioni con il mio particolare architettura. Sto cercando di installare Pycrypto (come una sussidiaria di Fabric) senza alcun risultato.Python per installare errore fatale: file gmp.h non trovato

Sono in esecuzione Mac 10.8.2, python 2.7.3 tramite Homebrew e XCode 4.6 - installazione con pip o easy_install (ho provato entrambi). Da quello che posso dire, il problema potrebbe riguardare la mia versione di XCode o le mie librerie. Sono stati installati gli strumenti della riga di comando per XCode e ho provato a inserire setenv ARCHFLAGS "-arch i386 -arch x86_64" nel mio file .cshrc. Ho anche provato ln -s /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer /Developer. Per quanto riguarda le librerie, ho provato a collegarle via ln -s /usr/local/lib/libgmp.dylib /usr/lib/libgmp.dylib - ma anche questo non ha funzionato.

L'errore è sempre lo stesso (vedi sotto), non importa quale angolo cerco. Qualsiasi aiuto sarebbe apprezzato.

/usr/local/share/python% pip install pycrypto 
Downloading/unpacking pycrypto 
    Running setup.py egg_info for package pycrypto 

Installing collected packages: pycrypto 
    Running setup.py install for pycrypto 
    building 'Crypto.PublicKey._fastmath' extension 
    /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -fno-strict-aliasing -fno-common -dynamic -arch i386 -arch x86_64 -pipe -mmacosx-version-min=10.8 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk -Wno-unused-value -Wno-empty-body -Qunused-arguments -fwrapv -Wall -Wstrict-prototypes -std=c99 -O3 -fomit-frame-pointer -Isrc/ -I/usr/include/ -I/usr/local/Cellar/python/2.7.3/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c src/_fastmath.c -o build/temp.macosx-10.8-intel-2.7/src/_fastmath.o 
src/_fastmath.c:36:11: fatal error: 'gmp.h' file not found 
# include <gmp.h> 
     ^
1 error generated. 
error: command '/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang' failed with exit status 1 
Complete output from command /usr/local/Cellar/python/2.7.3/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python -c "import setuptools;__file__='/var/folders/ym/v8l23q_x2xz_qhx3m84n6ym00005fr/T/pip-build/pycrypto/setup.py';exec(compile(open(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /var/folders/ym/v8l23q_x2xz_qhx3m84n6ym00005fr/T/pip-Xb7nGV-record/install-record.txt --single-version-externally-managed: 
running install 

running build 

running build_py 

running build_ext 

running build_configure 

building 'Crypto.PublicKey._fastmath' extension 

/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -fno-strict-aliasing -fno-common -dynamic -arch i386 -arch x86_64 -pipe -mmacosx-version-min=10.8 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk -Wno-unused-value -Wno-empty-body -Qunused-arguments -fwrapv -Wall -Wstrict-prototypes -std=c99 -O3 -fomit-frame-pointer -Isrc/ -I/usr/include/ -I/usr/local/Cellar/python/2.7.3/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c src/_fastmath.c -o build/temp.macosx-10.8-intel-2.7/src/_fastmath.o 

src/_fastmath.c:36:11: fatal error: 'gmp.h' file not found 

# include <gmp.h> 

    ^

1 error generated. 

error: command '/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain /usr/bin/clang' failed with exit status 1 

---------------------------------------- 
Command /usr/local/Cellar/python/2.7.3/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python -c "import setuptools;__file__='/var/folders/ym/v8l23q_x2xz_qhx3m84n6ym00005fr/T/pip-build/pycrypto/setup.py';exec(compile(open(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /var/folders/ym/v8l23q_x2xz_qhx3m84n6ym00005fr/T/pip-Xb7nGV-record/install-record.txt --single-version-externally-managed failed with error code 1 in /var/folders/ym/v8l23q_x2xz_qhx3m84n6ym00005fr/T/pip-build/pycrypto 
Storing complete log in /Users/me/.pip/pip.log 

L'errore quando provo a chiamare Tessuto:

Traceback (most recent call last): 
    File "/usr/local/share/python/fab", line 5, in <module> 
from pkg_resources import load_entry_point 
    File "/usr/local/Cellar/python/2.7.3/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/distribute-0.6.28-py2.7.egg/pkg_resources.py", line 2815, in <module> 
working_set.require(__requires__) 
    File "/usr/local/Cellar/python/2.7.3/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/distribute-0.6.28-py2.7.egg/pkg_resources.py", line 690, in require 
needed = self.resolve(parse_requirements(requirements)) 
    File "/usr/local/Cellar/python/2.7.3/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/distribute-0.6.28-py2.7.egg/pkg_resources.py", line 588, in resolve 
raise DistributionNotFound(req) 
pkg_resources.DistributionNotFound: pycrypto>=2.1,!=2.4 

risposta

1

ho finalmente capito che la radice del mio problema era in un'incompatibilità tra le versioni di tessuto e pycrypto. Dopo aver eseguito il downgrade della versione di Fabric in 1.2.6, non ho più ricevuto gli errori sopra riportati. Quindi, ho usato il tutorial come punto di partenza. Tuttavia, nonostante il tutorial e la versione precedente di Fabric, ho ancora ricevuto l'errore PyCrypto >= 2.1, !=2.4. Alla fine ho installato Pythonto 2.2 dal sorgente (dal momento che apparentemente pip installerà solo v. 2.0.1 anche quando la designazione di pip -Iv install pycrypto==2.2 per this e v. 2.6 ha provocato l'errore gmp.h). Alla fine, tutto ha funzionato.

2

Semplicemente collegando gmppylib non è utile perché pycrpto ha bisogno di compilare alcuni file C che comprenderà gmp.h. Dovresti avere la libreria GMP installata che conterrà gmp.h. Sembra che tu debba installare GMP sul tuo Mac OS. I seguenti due link dovrebbero esserti utili.

+0

Sfortunatamente, nessuno di questi ha funzionato. Ma grazie. – cosmosis

0

Ecco la correzione che ha funzionato per me:

https://medium.com/software-bugs/84afab886a1e

È necessario creare un link simbolico in base all'intestazione di installazione percorso di inclusione (-I) in, ma incidente. Esempio: estensione

edificio 'Crypto.PublicKey._fastmath'

/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -fno-strict-aliasing -fno- common -dynamic -pipe -march = nativo -mmacosx-version-min = 10.7 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.7.sdk -isystem/Applicazioni/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.7.sdk/usr/include -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.7.sdk/usr/include -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.7.sdk/usr/X11/include -Wno-unused-value - Wno-empty-body -Qunused-arguments -fwrap v -Wall -Wintict-prototypes -std = c99 -O3 -fomit-frame-pointer -Isrc/* -I/usr/include/- * I/usr/local/Cellar/python/2.7.3/Framework/Python.framework/Versions/2.7/include/python2.7 -c src/_fastmath.c -o build/temp.MacOSX-10.7-x86_64-2.7/src/_fastmath.o

src/_fastmath.c: 36: 11: errore fatale: file 'gmp.h' non trovato

4

sono stato in grado di ottenere pycrypto da installare utilizzando il seguente comando:

CFLAGS=-I/opt/local/include pip install pycrypto 

ho GMP installato tramite MacPorts, in esecuzione su OSX 10.8.3 con Python 2.7.2 da python.org. In questo caso sto installando in un virtualenv.

io capisco il seguente avviso quando si utilizza pycrypto, ma funziona ancora:

/Users/me/.virtualenvs/blah/lib/python2.7/site-packages/Crypto/Util/number.py:57: PowmInsecureWarning: Not using mpz_powm_sec. You should rebuild using libgmp >= 5 to avoid timing attack vulnerability. 
    _warn("Not using mpz_powm_sec. You should rebuild using libgmp >= 5 to avoid timing attack vulnerability.", PowmInsecureWarning) 
41

Se si utilizza Homebrew, questo dovrebbe fare il trucco:

brew install gmp 
env "CFLAGS=-I/usr/local/include -L/usr/local/lib" pip install pycrypto 

Utilizzando ENV garantirà che funziona solo questa volta. Se è necessario installare pycrypto in un secondo momento in un'altra sessione, esportare la variabile.

export "CFLAGS=-I/usr/local/include -L/usr/local/lib" 
pip install pycrypto 
+1

Ha funzionato perfettamente per me, grazie! –

+0

grazie. 'env" CFLAGS = -I/usr/include/gmp -L/usr/lib/gmp "pip installa pycrypto' ha funzionato per me su Solaris 11.3. –

+1

Funziona. Molte grazie. Mi hai salvato la vita. – harukaeru