设为首页 收藏本站
查看: 887|回复: 0

[经验分享] python-twisted在win下的安装

[复制链接]
YunVN网友  发表于 2017-4-27 12:48:41 |阅读模式
  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.

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-370034-1-1.html 上篇帖子: [python]File文件操作 下篇帖子: python cgi 的编写
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表