Python 轻松安装pycrypto的问题

Python 轻松安装pycrypto的问题,python,pycrypto,Python,Pycrypto,我正在尝试使用easy_install在osx上安装pycrypto,但出现以下错误: easy_install pycrypto Searching for pycrypto Reading http://pypi.python.org/simple/pycrypto/ Reading http://pycrypto.sourceforge.net Reading http://www.pycrypto.org/ Reading http://www.amk.ca/python/code/cr

我正在尝试使用easy_install在osx上安装pycrypto,但出现以下错误:

easy_install pycrypto
Searching for pycrypto
Reading http://pypi.python.org/simple/pycrypto/
Reading http://pycrypto.sourceforge.net
Reading http://www.pycrypto.org/
Reading http://www.amk.ca/python/code/crypto
Best match: pycrypto 2.3
Downloading http://ftp.dlitz.net/pub/dlitz/crypto/pycrypto/pycrypto-2.3.tar.gz
Processing pycrypto-2.3.tar.gz
Running pycrypto-2.3/setup.py -q bdist_egg --dist-dir /var/folders/3D/3D07iptvHZuzuYaeQDMFIU+++TI/-Tmp-/easy_install-00HgRU/pycrypto-2.3/egg-dist-tmp-BWGYsg
warning: GMP library not found; Not building Crypto.PublicKey._fastmath.
/usr/libexec/gcc/powerpc-apple-darwin10/4.2.1/as: assembler (/usr/bin/../libexec/gcc/darwin/ppc/as or /usr/bin/../local/libexec/gcc/darwin/ppc/as) for architecture ppc not installed
Installed assemblers are:
/usr/bin/../libexec/gcc/darwin/x86_64/as for architecture x86_64
/usr/bin/../libexec/gcc/darwin/i386/as for architecture i386
src/MD2.c:134: fatal error: error writing to -: Broken pipe
compilation terminated.
lipo: can't open input file: /var/folders/3D/3D07iptvHZuzuYaeQDMFIU+++TI/-Tmp-//ccoXuPRo.out (No such file or directory)
error: Setup script exited with error: command 'gcc-4.2' failed with exit status 1

是的,这是安装Xcode 4的结果。它尝试为ppc构建,尽管Xcode 4不再具有相关的位。查看此问题以了解解决方法:

我的
~/.bash_配置文件中有此内容来解决此问题:

# Set compile flags to not try to compile for PPC (no longer supported by xcode 4)
# (this is required for eg building pycrypto)
export ARCHFLAGS="-arch i386 -arch x86_64"
xCode 5.1

ARCHFLAGS=-Wno-error=unused-command-line-argument-hard-error-in-future pip install pycrypto

看起来OSX 10.9让这变得有点困难。以下是我做的额外工作:

brew安装libffi

如果您看到关于如何安装“keg only”的警告,这意味着homebrew没有链接它,因此您需要使用
export PKG_CONFIG_PATH=/usr/local/opt/libffi/lib/pkgconfig
提供更多信息。此时,由于默认情况下OSX现在在警告标志上消失,因此安装将中断,因此也将抑制该行为:

export CFLAGS=-Qunused-arguments
export CPPFLAGS=-Qunused-arguments

那么您应该能够使用
pip

安装,在执行此操作之前,我刚刚安装了xcode 4,这可能会影响它吗?您是否在PPC机器上运行??您的错误抱怨它找不到二进制软件包的汇编程序,这肯定有效,但如果不明显,您需要在保存文件后打开一个新的终端窗口,以便更改生效!任何旧的终端窗口都不会看到更改。