python-twisted在win下的安装

1.下载页面:

http://twistedmatrix.com/trac/wiki/Downloads

https://launchpad.net/pyopenssl

https://www.dlitz.net/software/pycrypto/ 

 

准备好工具

安装工具:http://pypi.python.org/pypi/setuptools

安装完成后在

D:\Python26\Scripts文件夹中找到easy_install.exe

把蛋拖进去

 

或者:

 

如果已经把egg文件下载到了本地,则easy_install xxx.egg就ok了,如何有依赖,则会自动下载安装,省心了。如果没有下载下来,网络安装更爽,直接 easy_install 包名,此时喝点咖啡休息一下,回过神来时已经安装好了。唯一一点不好的感觉是,easy_install现在还不支持自动卸载,网上流传的用easy_install -m xxx来卸载,是不行了,这个命令式用来安装同一个包的多个版本的

2.安装

1)download the twisted,then install the twisted windows "sumo"

2)download and install pyopenssl

3)download and install pycrypto

4)verify:

python

>>>import twisted

如果没有发生错误,则表示成功

 

安装pycrypto时可能会提示错误:

Unable to find vcvarsall.bat

解决方法是(前提是必须安mingw,假设mingw安在D:\CodeBlocks\中)

首先:

set path=D:\CodeBlocks\MinGW;D:\CodeBlocks\MinGW\bin;%path%

然后:

python setup.py  build --compiler=mingw32

最后:

python setup.py  install

 

还需要在这里下载安装pyasn1

http://sourceforge.net/projects/pyasn1/

 

 

 3.从源代码安装

$ tar -xjvf ~/downloads/TwistedSumo-2005-03-22.tar.bz2

    TwistedSumo-2005-03-22/

    TwistedSumo-2005-03-22/bin/

    ...

    TwistedSumo-2005-03-22/README

    TwistedSumo-2005-03-22/LICENSE

    TwistedSumo-2005-03-22/setup.py

    TwistedSumo-2005-03-22/ZopeInterface-3.0.1.tgz

Next, enter the TwistedSumo-version directory. Twisted depends on the zope.interface package, which is bundled in the Twisted Sumo distribution. Unzip the ZopeInterface tarball:

    $ tar -xzvf ZopeInterface-3.0.1.tgz

    ZopeInterface-3.0.1/

    ZopeInterface-3.0.1/Support/

    ZopeInterface-3.0.1/Support/zpkgsetup/

    ZopeInterface-3.0.1/Support/zpkgsetup/publication.py

    ...

    ZopeInterface-3.0.1/setup.py

    ZopeInterface-3.0.1/setup.cfg

    ZopeInterface-3.0.1/MANIFEST

 

Enter the ZopeInterface-<version> directory, and run the command python setup.py install. This command will build and install the zope.interface package in your python installation's lib/site-packages/twisted directory. You'll need to have administrative/root permissions to do this, so use su or sudo to increase your permission level if necessary:

    $ cd ZopeInterface-3.0.1

    $ python setup.py install

    running install

    running build

    running build_py

    running build_ext

    building 'zope.interface._zope_interface_coptimizations' extension

    ...

    running install_lib

    copying build/lib.linux-i686-2.4/zope/interface/_zope_interface_coptimizations.so ->

    /usr/lib/python2.4/site-packages/zope/interface

    writing byte-compilation script '/tmp/tmpdY9dA9.py'

    /usr/bin/python -O /tmp/tmpdY9dA9.py

    removing /tmp/tmpdY9dA9.py

 

Once zope.interface is installed, you're ready to install Twisted. In this TwistedSumo-<version> directory, run the command python setup.py install. The command will compile the Twisted C modules and install Twisted:

    $ cd TwistedSumo-2005-03-22

    $ python setup.py install

    Password:

    running install

    running build

    running build_py

    ...

    running install_data

 

 

If you have more than one version of Python installed, keep in mind that Twisted will be installed for only the version of Python you're using when you run setup.py. The examples in this book require Python 2.3 or higher. To check your Python version, run python -V.

 

Congratulations—you've installed Twisted! You can make sure the installation worked by importing the Twisted package from an interactive Python prompt:

    $ python

    Python 2.3 (#1, Sep 13 2003, 00:49:11)

    [GCC 3.3 20030304 (Apple Computer, Inc. build 1495)] on darwin

    Type "help", "copyright", "credits" or "license" for more information.

    >>> import twisted

    >>>

 

If the import twisted statement runs with no errors, you have a working Twisted install.

Next, download the latest release of PyOpenSSL from http://pyopenssl.sourceforge.net. PyOpenSSL works on top of the OpenSSL library, so you'll need to make sure you have OpenSSL installed first. Mac OS X comes with OpenSSL installed, along with its header files, and all Linux and BSD distributions should have a package available (if not installed by default).

 

If you're using a really obscure operating system that doesn't include OpenSSL, you can download and compile the source package from http://www.openssl.org.

 

To install PyOpenSSL, follow the same steps you did when installing Twisted. First, extract the contents of the downloaded file:

    $ tar -zxvf pyOpenSSL-0.6.tar.gz

    pyOpenSSL-0.6/

    pyOpenSSL-0.6/doc/

    pyOpenSSL-0.6/doc/html/

    ...

    pyOpenSSL-0.6/_ _init_ _.py

    pyOpenSSL-0.6/ChangeLog

    pyOpenSSL-0.6/COPYING

    pyOpenSSL-0.6/version.py

 

Next, switch to the PyOpenSSL directory and run python setup.py install as root or an administrative user:

    $ cd pyOpenSSL-0.6

    $ python setup.py install

    running install

    running build

    running build_py

    creating build

    ...

    byte-compiling

    /System/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/site-packages/

    OpenSSL/__init__.py to _ _init_ _.pyc

    byte-compiling

    /System/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/site-packages/

    OpenSSL/version.py to version.pyc

 

When the installation is complete, test to confirm that the OpenSSL package is now available, and that Twisted is making use of it in its internet.ssl module:

    $ python

    Python 2.3 (#1, Sep 13 2003, 00:49:11)

    [GCC 3.3 20030304 (Apple Computer, Inc. build 1495)] on darwin

    Type "help", "copyright", "credits" or "license" for more information.

    >>> import OpenSSL

    >>> import twisted.internet.ssl

    >>> twisted.internet.ssl.SSL

    <module 'OpenSSL.SSL' from

    '/System/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/site-

    packages/OpenSSL/SSL.so'>

 

If you don't see any errors, you've successfully added SSL support to your Twisted installation.

The final package to install is PyCrypto. PyCrypto, the Python Cryptography Toolkit, is a package developed by A. M. Kuchling that contains implementations of many cryptographic functions. Twisted uses PyCrypto to support SSH connections.

Start by downloading PyCrypto from http://www.amk.ca/python/code/crypto.html. Then extract the package:

    $ tar -xzvf pycrypto-2.0.tar.gz

    pycrypto-2.0/

    pycrypto-2.0/_ _init_ _.py

    pycrypto-2.0/ACKS

    pycrypto-2.0/ChangeLog

    ...

    pycrypto-2.0/Util/test/prime_speed.py

    pycrypto-2.0/Util/test.py

 

Run the now-familiar python setup.py install (as root or an administrative user) in the PyCrypto directory:

    $ cd pycrypto-2.0

    $ python setup.py install

    running install

    running build

    running build_py

    creating build

    ...

    byte-compiling

    /System/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/site-packages/

    Crypto/Util/RFC1751.py to RFC1751.pyc

    byte-compiling

    /System/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/site-packages/

    Crypto/Util/test.py to test.pyc

 

To verify that the package installed correctly, import it from an interactive Python prompt. You can also make sure Twisted's twisted.conch.ssh.transport module is now using PyCrypto's RSA implementation:

    $ python

    Python 2.3 (#1, Sep 13 2003, 00:49:11)

    [GCC 3.3 20030304 (Apple Computer, Inc. build 1495)] on darwin

    Type "help", "copyright", "credits" or "license" for more information.

    >>> import Crypto

    >>> import twisted.conch.ssh.transport

    >>> twisted.conch.ssh.transport.RSA

    <module 'Crypto.PublicKey.RSA' from

    '/System/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/site-

    packages/Crypto/PublicKey/RSA.pyc'>

 

And that's it! You've installed PyCrypto from source. At this point you have a complete, working Twisted installation, including support for SSL and SSH connections.

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值