Linux下Python网络编程框架-Twisted安装手记

Twisted是python下的用来进行网络服务和应用程序编程的框架,安装Twisted前需要系统预先安装有python。
一、安装Twisted
1、下载Twisted
这里下载Twisted,有win32,source,mac版本,win32下有支持python2.4和2.5的两个版本,可以根据你的python版本下载,今天是在linux下,所以直接下载source版本就可以了。目前的版本号是Twisted-8.1.0
2、安装Twisted
下载好Twisted后,进入到下载目录,解压:

[root@codebreaker ~]#tar -jvxf Twisted-8.1.0.tar.bz2
解压完成后进入相应目录:
[root@codebreaker ~]#cd Twisted-8.1.0
执行安装:
[root@codebreaker Twisted-8.1.0]#python setup.py install
安装完成后进入python,测试Twisted是否安装成功
[root@codebreaker Twisted-8.1.0]# python
Python 2.5 (r25:51908, May 26 2008, 17:47:47)
[GCC 3.4.6 20060404 (Red Hat 3.4.6-3)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import twisted
>>>
如果没有错误发生,说明Twisted已经安装成功了
二、安装PyOpenSSL
PyOpenSSL是OpenSSL的python接口,用于给Twisted提供加密传输支持(SSL),这个软件包并不是必须要安装的,但是如果不安装你将无法使用Twisted的SSL功能。(很小的一个包,装了吧,没坏处)
1、下载PyOpenSSL,目前的安装包是pyOpenSSL-0.7.tar.gz
2、安装PyOpenSSL
[root@codebreaker ~]#tar -zvxf pyOpenSSL-0.7.tar.gz
[root@codebreaker ~]#cd pyOpenSSL-0.7
[root@codebreaker pyOpenSSL-0.7]#python setup.py install
3、测试是否安装成功
[root@codebreaker ~]# python
Python 2.5 (r25:51908, May 26 2008, 17:47:47)
[GCC 3.4.6 20060404 (Red Hat 3.4.6-3)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import OpenSSL
>>> import twisted.internet.ssl
>>> twisted.internet.ssl
<module ‘twisted.internet.ssl’ from ‘/usr/python/lib/python2.5/site-packages/Twisted-8.1.0-py2.5-linux-i686.egg/twisted/internet/ssl.pyc’>
如果出现类似提示,说明pyOpenSSL模块已经安装成功了,否则,请检查上面的安装过程。
三、安装PyCrypto
PyCrypto跟pyOpenSSL一样,也是Twisted的一个支持工具集,不同的是PyCrypto提供的是SSH连接功能。
1、下载PyCrypto,目前的安装包是pycrypto-2.0.1.tar.tar
2、安装PyCrypto
[root@codebreaker ~]#tar -zvxf pycrypto-2.0.1.tar.tar
[root@codebreaker ~]#cd pycrypto-2.0.1
[root@codebreaker pycrypto-2.0.1]#python setup.py install
3、测试是否安装成功
[root@codebreaker ~]# python
Python 2.5 (r25:51908, May 26 2008, 17:47:47)
[GCC 3.4.6 20060404 (Red Hat 3.4.6-3)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import Crypto
>>> import twisted.conch.ssh.transport
>>> print Crypto.PublicKey.RSA
<module ‘Crypto.PublicKey.RSA’ from ‘/usr/python/lib/python2.5/site-packages/Crypto/PublicKey/RSA.pyc’>
>>>
提示RSA.pyc位置,说明已经安装成功了。
至此,安装完成。
 
 
 
 

Share and Enjoy:
  • Print this article!
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google Bookmarks
  • LinkedIn
  • Live
  • MySpace
  • RSS
  • Slashdot
  • Technorati
  • TwitThis

Related posts:

  1. 安装django环境
  2. Python Imaging Library (PIL)

Leave a Reply

 

 

 

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

*
To prove you're a person (not a spam script), type the security word shown in the picture. Click on the picture to hear an audio file of the word.
Click to hear an audio file of the anti-spam word

Contact us

Admin: Bryan Wu