python安装twisted出现拒绝安装_安装twisted遇到的坑

在使用twisted框架的时候,我们需要知道他是干什么的?

twisted支持很多种协议,包括传输层的TCP, UDP, TLS和引用层的HTTP和FTP等。

twisted框架其主要发行版本是以python2为主的,最新版本是基于python2.7的twisted-15.4.0,目前为止,没有基于python3的twisted稳定的发行版。

在window中,twisted的实现是基于IO操作完成端口技术。保证了底层高效的将IO时间通知给框架和应用程序。

在Linux系统中,twisted的实现基于epoll技术(epoll不限制监听的socket的次数,可以执行回调方法),epoll显著提高程序在大量的并发中,只有少数活跃的情况下提高了CPU的利用率。

安装twisted框架以及组件

安装twisted的时候,要将解释器的环境切换到python2中

安装twisted框:

https://pypi.python.org/simple/twisted

里面有很多版本,最后下载exe格式的可以自动安装,我下载的版本是Twisted-15.4.0.win-amd64-py2.7.exe,安装完成后,你会在C:\Python27\Lib\site-packages目录下看到twisted文件夹

安装zope.interface

https://pypi.python.org/simple/zope.interface/

很多版本,根据windows位数,python版本号,以及exe文件傻瓜式安装,我选择的版本是 zope.interface-4.1.1.win-amd64-py2.7.exe,安装完成后,你会在C:\Python27\Lib\site-packages目录下看到zope文件夹

验证安装成功

import twisted

如果在安装过程中出现:Python version 2.7 required, which was not found in the registry 这个错误的时候,就建立一个register.py的文件,然后执行下面的脚本。

import sys

from _winreg import *

# tweak as necessary

version = sys.version[:3]

installpath = sys.prefix

regpath = "SOFTWARE\\Python\\Pythoncore\\%s\\" % (version)

installkey = "InstallPath"

pythonkey = "PythonPath"

pythonpath = "%s;%s\\Lib\\;%s\\DLLs\\" % (

installpath, installpath, installpath

)

def RegisterPy():

try:

reg = OpenKey(HKEY_CURRENT_USER, regpath)

except EnvironmentError as e:

try:

reg = CreateKey(HKEY_CURRENT_USER, regpath)

SetValue(reg, installkey, REG_SZ, installpath)

SetValue(reg, pythonkey, REG_SZ, pythonpath)

CloseKey(reg)

except:

print "*** Unable to register!"

return

print "--- Python", version, "is now registered!"

return

if (QueryValue(reg, installkey) == installpath and

QueryValue(reg, pythonkey) == pythonpath):

CloseKey(reg)

print "=== Python", version, "is already registered!"

return

CloseKey(reg)

print "*** Unable to register!"

print "*** You probably have another Python installation!"

if __name__ == "__main__":

RegisterPy()

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值