CentOS 编译安装 PyCrypto
来源:互联网 发布:json字符串base64加密 编辑:程序博客网 时间:2024/05/22 13:30
转载自:http://bugcharmer.blogspot.com/2012/07/building-pycrypto-on-amazon-ec2.html
Step 1 - Install gcc/make
$ sudo yum install gcc
$ sudo yum install make
That was easy.
Step 2 - Install the GNU MP Arithmetic Library
$ wget ftp://ftp.gmplib.org/pub/gmp-5.0.5/gmp-5.0.5.tar.bz2
$ bunzip2 gmp-5.0.5.tar.bz2
$ cd gmp-5.0.5
$ sudo ./configure
$ sudo make
$ sudo make check
$ sudo make install
$ cd
Still not too bad.
Step 3 - Install MPIR
$ wget http://www.mpir.org/mpir-2.5.1.tar.bz2
$ bunzip mpir-2.5.1.tar.bz2
$ cd mpir-2.5.1
$ sudo ./configure
$ sudo make
$ sudo make check
$ sudo make install
$ cd
Everything worked up through here.
Intermission
There are two problems you’ll run into if you try to build PyCrypto at this point: errors from missing header files and, once you resolve those, runtime errors complaining about an undefined symbol for rpl_malloc. Let’s fix that.
Step 4 - Install the Python development headers
$ sudo yum install python-devel
Easy fix.
Step 5 - Download PyCrypto
$ wget http://ftp.dlitz.net/pub/dlitz/crypto/pycrypto/pycrypto-2.6.tar.gz
$ tar xzvf pycrypto-2.6.tar.gz
$ cd pycrypto-2.6
Step 6 - Edit the configure script
$ [favorite editor] configure
Find the this section of the script (I added line numbers):
: if test $ac_cv_func_malloc_0_nonnull = yes; then:
:
: $as_echo "#define HAVE MALLOC 1" >> confdefs.h
:
: else
: $as_echo "define HAVE_MALLOC 0" >> confdefs.h
:
: case " $LIBOBJS " in
: *" malloc.$ac_objext "* ) ;;
: *) LIBOBJS = "$LIBOBJS malloc.$ac_objext"
: ;;
: esac
:
;
: $as_echo "define malloc rpl_malloc" >>confdefs.h
:
: fi
Keep line 3867, but comment out the rest. Save and exit.
or
$ export ac_cv_func_malloc_0_nonnull=yes
The problem is that when you try to build PyCrypto, autotools thinks that we’re using rpl_malloc instead of malloc. I’m not sure how to fix this problem the right way, but this hack will get rid of the check and just have it use malloc. If someone knows the right way to fix this, please say something in the comments and I’ll update this post.
否则会有如下错误:
ImportError: /usr/local/lib/python2.6/dist-packages/pycrypto-2.6-py2.6-linux-x86_64.egg/Crypto/Cipher/_AES.so: undefined symbol: rpl_malloc
Step 7 - Build PyCrypto
$ python setup.py build
$ sudo python.setup.py install
Step 8 - Test PyCrypto
$ python
>>> from Crypto.Cipher import AES
If this works, you should be good to go.
If it fails, you did something wrong. You can either rm -r pycrypto-2.6 and re-extract the archive or just rm -r the build folder then grep for anything that says “rpl_malloc” and comment it out. Also edit config.status and change ‘D[“HAVE_MALLOC”]=” 0”’ to say ‘=” 1”’. This is what I did the first time, but when I decided to write this up I started over to try to get it right from the start.
- CentOS 编译安装 PyCrypto
- centos安装pycrypto
- 安装pycrypto编译错误的解决办法
- 安装PyCrypto
- 安装pycrypto
- python安装pycrypto
- PyCrypto 安装中的问题
- python安装pycrypto
- python安装pycrypto
- python3.4 安装 pycrypto
- python3.5 安装PyCrypto
- PyCrypto
- pycrypto
- PyCrypto安装和使用示例
- python库pycrypto的安装
- linux环境下安装 pycrypto
- win10 Python 3.6 安装 pycrypto
- CentOS编译安装lamp
- [CS@Nets][编译原理]一个栈式计算机的加法语言编译器
- 南京揭秘响一声电话吸费 声讯电话平台
- 15年省赛和东北区域赛总结
- Unix类ls的小程序
- R软件学习笔记—Legend
- CentOS 编译安装 PyCrypto
- 威海高收费电话加盟 2014好项目 电话群呼器
- 时间
- ruby元编程读后感
- 轮廓处理之一
- 线程中sleep()方法和yeild()方法的区别
- Oracle创建用户、表空间、导入导出、...命令
- 记修改论文的感受
- 【连载】 .Net cad二次开发(二)