发布于 2016-01-14 09:28:49 | 1041 次阅读 | 评论: 1 | 来源: PHPERZ
M2Crypto Python加密库
M2Crypto 是一个 Python 语言对 OpenSSL 的封装,支持包括 RSA、DSA、DH、HMACs、消息摘要、对称加密如 AES,以及客户端和服务器端的 SSL 功能;HTTPS 等。
pip install M2Crypto
报错信息:
swig -python -I/usr/local/include/python2.7 -I/usr/include -includeall -o SWIG/_m2crypto_wrap.c SWIG/_m2crypto.i
/usr/include/openssl/opensslconf.h:31: Error: CPP #error ""This openssl-devel package does not work your architecture?"". Use the -cpperraswarn option to continue swig processing.
error: command 'swig' failed with exit status 1
----------------------------------------
Command "/usr/local/bin/python -c "import setuptools, tokenize;__file__='/tmp/pip-build-_WW9OZ/M2Crypto/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --r
或者报错:
swigging SWIG/_m2crypto.i to SWIG/_m2crypto_wrap.c
swig -python -I/usr/include/python2.6 -I/usr/include -includeall -modern -builtin -outdir build/lib.linux-i686-2.6/M2Crypto -D__i386__ -o SWIG/_m2crypto_wrap.c SWIG/_m2crypto.i
swig error : Unrecognized option -builtin
Use 'swig -help' for available options.
error: command 'swig' failed with exit status 1
以上都是swig的报错,原因是swig的版本过低导致的。
查看swig版本1.3.已经比较老旧了,swig -python -help 也未找到相关options:
[root@localhost ~]# rpm -qa | grep swig
swig-1.3.40-6.el6.x86_64
解决办法有两个:
升级swig版本
wget -O swig-3.0.7.tar.gz http://prdownloads.sourceforge.net/swig/swig-3.0.7.tar.gz
tar zxf swig-3.0.7.tar.gz
cd swig-3.0.7
./configure --prefix=/usr
make && make install
2.手动安装M2Crypto
[root@localhost ~]#wget
[root@localhost ~]#unzip master.zip
[root@localhost ~]#cd M2Crypto-master
[root@localhost ~]#python setup.py install
success!