本文介绍了在 Windows 上运行 Portia (scrapy)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经根据本指南在 Windows 8.1 上成功安装了 Portia http://doc.scrapy.org/en/latest/intro/install.html#windows(使用 pip 而不是 easy_install).

I have succefully installed Portia on Windows 8.1 according to this guide http://doc.scrapy.org/en/latest/intro/install.html#windows (used pip instead of easy_install).

当通过 twistd.py -n slyd 启动 slyd 时,一切似乎都正常,直到我打开网站 http://localhost:9001/static/main.html.控制台窗口显示以下错误:

When starting slyd via twistd.py -n slyd everything seems to work fine until I open the website http://localhost:9001/static/main.html. The following error is displayed in the console window:

2014-06-03 19:05:56+0200 [-] Log opened.
2014-06-03 19:05:56+0200 [-] twistd 14.0.0 (C:\Python27\python.exe 2.7.7) starting up.
2014-06-03 19:05:56+0200 [-] reactor class: twisted.internet.selectreactor.SelectReactor.
2014-06-03 19:05:56+0200 [-] Site starting on 9001
2014-06-03 19:05:56+0200 [-] Starting factory <twisted.web.server.Site instance at 0x040E0CB0>
2014-06-03 19:07:08+0200 [HTTPChannel,0,127.0.0.1] Unhandled Error
        Traceback (most recent call last):
          File "C:\Python27\lib\site-packages\twisted\protocols\basic.py", line 571, in dataReceived
            why = self.lineReceived(line)
          File "C:\Python27\lib\site-packages\twisted\web\http.py", line 1656, in lineReceived
            self.allContentReceived()
          File "C:\Python27\lib\site-packages\twisted\web\http.py", line 1731, in allContentReceived
            req.requestReceived(command, path, version)
          File "C:\Python27\lib\site-packages\twisted\web\http.py", line 827, in requestReceived
            self.process()
        --- <exception caught here> ---
          File "C:\Python27\lib\site-packages\twisted\web\server.py", line 189, in process
            self.render(resrc)
          File "C:\Python27\lib\site-packages\twisted\web\server.py", line 238, in render
            body = resrc.render(self)
          File "C:\Python27\lib\site-packages\twisted\web\resource.py", line 250, in render
            return m(request)
          File "C:\Python27\lib\site-packages\twisted\web\static.py", line 631, in render_GET
            producer.start()
          File "C:\Python27\lib\site-packages\twisted\web\static.py", line 710, in start
            self.request.registerProducer(self, False)
          File "C:\Python27\lib\site-packages\twisted\web\http.py", line 873, in registerProducer
            self.transport.registerProducer(producer, streaming)
          File "C:\Python27\lib\site-packages\twisted\internet\_newtls.py", line 233, in registerProducer
            FileDescriptor.registerProducer(self, producer, streaming)
          File "C:\Python27\lib\site-packages\twisted\internet\abstract.py", line 112, in registerProducer
            producer.resumeProducing()
          File "C:\Python27\lib\site-packages\twisted\web\static.py", line 720, in resumeProducing
            self.request.write(data)
          File "C:\Python27\lib\site-packages\twisted\web\server.py", line 217, in write
            http.Request.write(self, data)
          File "C:\Python27\lib\site-packages\twisted\web\http.py", line 1002, in write
            value = networkString('%s' % (value,))
          File "C:\Python27\lib\site-packages\twisted\python\compat.py", line 364, in networkString
            raise TypeError("Can only pass-through bytes on Python 2")
        exceptions.TypeError: Can only pass-through bytes on Python 2

2014-06-03 19:07:08+0200 [HTTPChannel,0,127.0.0.1] "127.0.0.1" - - [03/Jun/2014:17:07:07 +0000] "GET /static/main.html H
TTP/1.1" 500 10874 "-" "Mozilla/5.0 (Windows NT 6.3; WOW64; rv:29.0) Gecko/20100101 Firefox/29.0"
2014-06-03 19:07:08+0200 [HTTPChannel,0,127.0.0.1] Unhandled Error
        Traceback (most recent call last):
        Failure: exceptions.RuntimeError: Producer was not unregistered for /static/main.html

我认为重要的信息是:

exceptions.TypeError: Can only pass-through bytes on Python 2

exceptions.RuntimeError: Producer was not unregistered for /static/main.html

知道如何解决这个问题吗?

Any idea how to solve this issue?

推荐答案

不幸的是,您被 Python 2.7.7 版本引入的回归所困扰:

You have unfortunately been bitten by a regression introduced by the Python 2.7.7 release:

http://bugs.python.org/issue21652

降级到 Python 2.7.6 或更早版本将暂时解决此问题.

Downgrading to Python 2.7.6 or earlier will address this issue for now.

这篇关于在 Windows 上运行 Portia (scrapy)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-28 16:01