我试图在Ubuntu服务器13.0和python 2.7中运行以下python代码
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()当我试图运行它时,它给了我以下错误:
ImportError: No module named twisted.web.client我已经在python和twisted.internet works中尝试过了,但没有使用twisted.web。有人有什么建议如何处理这样的问题吗?
谢谢
发布于 2013-10-11 12:07:15
你安装了扭曲的网络吗?您必须在Ubuntu下面安装python-twisted-web包:
sudo apt-get install python-twisted-webhttps://stackoverflow.com/questions/19317087
复制相似问题