首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >导入时找不到twisted.web

导入时找不到twisted.web
EN

Stack Overflow用户
提问于 2013-10-11 11:30:25
回答 1查看 4.6K关注 0票数 2

我试图在Ubuntu服务器13.0和python 2.7中运行以下python代码

代码语言:javascript
复制
from twisted.python.log import err
from twisted.web.client import Agent
from twisted.internet import reactor
from twisted.internet.ssl import ClientContextFactory
from twisted.web.http_headers import Headers
from stringproducer import StringProducer
class WebClientContextFactory(ClientContextFactory):
    def getContext(self, hostname, port):
        return ClientContextFactory.getContext(self)

def display(response):
    print "Received response"
    print response

def main():
    contextFactory = WebClientContextFactory()
    agent = Agent(reactor, contextFactory)


    d = agent.request("POST", "https://myweburl");


    d.addCallbacks(display, err)
    d.addCallback(lambda ignored: reactor.stop())
    reactor.run()

if __name__ == "__main__":
    main()

当我试图运行它时,它给了我以下错误:

代码语言:javascript
复制
ImportError: No module named twisted.web.client

我已经在python和twisted.internet works中尝试过了,但没有使用twisted.web。有人有什么建议如何处理这样的问题吗?

谢谢

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2013-10-11 12:07:15

你安装了扭曲的网络吗?您必须在Ubuntu下面安装python-twisted-web包:

代码语言:javascript
复制
sudo apt-get install python-twisted-web
票数 5
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/19317087

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档