1. 保存信息如下
D:\python3\BR16>scrapy crawl BR16B -L WARNING Unhandled error in Deferred: 2016-10-10 14:19:05 [twisted] CRITICAL: Unhandled error in Deferred: Traceback (most recent call last): File "d:\python35\lib\site-packages\scrapy\commands\crawl.py", line 57, in run self.crawler_process.crawl(spname, **opts.spargs) File "d:\python35\lib\site-packages\scrapy\crawler.py", line 163, in crawl return self._crawl(crawler, *args, **kwargs) File "d:\python35\lib\site-packages\scrapy\crawler.py", line 167, in _crawl d = crawler.crawl(*args, **kwargs) File "d:\python35\lib\site-packages\twisted\internet\defer.py", line 1274, in unwindGenerator return _inlineCallbacks(None, gen, Deferred()) ------ File "d:\python35\lib\site-packages\twisted\internet\defer.py", line 1128, in _inlineCallbacks result = g.send(result) File "d:\python35\lib\site-packages\scrapy\crawler.py", line 72, in crawl self.engine = self._create_engine() File "d:\python35\lib\site-packages\scrapy\crawler.py", line 97, in _create_engine return ExecutionEngine(self, lambda _: self.stop()) File "d:\python35\lib\site-packages\scrapy\core\engine.py", line 68, in __init__ self.downloader = downloader_cls(crawler) File "d:\python35\lib\site-packages\scrapy\core\downloader\__init__.py", line 88, in __init__ self.middleware = DownloaderMiddlewareManager.from_crawler(crawler) File "d:\python35\lib\site-packages\scrapy\middleware.py", line 58, in from_crawler return cls.from_settings(crawler.settings, crawler) File "d:\python35\lib\site-packages\scrapy\middleware.py", line 34, in from_settings mwcls = load_object(clspath) File "d:\python35\lib\site-packages\scrapy\utils\misc.py", line 44, in load_object mod = import_module(module) File "d:\python35\lib\importlib\__init__.py", line 126, in import_module return _bootstrap._gcd_import(name[level:], package, level) File " ", line 986, in _gcd_import File " ", line 969, in _find_and_load File " ", line 958, in _find_and_load_unlocked File " ", line 673, in _load_unlocked File " ", line 665, in exec_module File " ", line 222, in _call_with_frames_removed File "d:\python35\lib\site-packages\scrapy\downloadermiddlewares\retry.py", line 23, in from scrapy.xlib.tx import ResponseFailed File "d:\python35\lib\site-packages\scrapy\xlib\tx\__init__.py", line 3, in from twisted.web import client File "d:\python35\lib\site-packages\twisted\web\client.py", line 42, in from twisted.internet.endpoints import TCP4ClientEndpoint, SSL4ClientEndpoint File "d:\python35\lib\site-packages\twisted\internet\endpoints.py", line 34, in from twisted.internet.stdio import StandardIO, PipeAddress File "d:\python35\lib\site-packages\twisted\internet\stdio.py", line 30, in from twisted.internet import _win32stdio builtins.ImportError: cannot import name '_win32stdio' 2016-10-10 14:19:06 [twisted] CRITICAL: Traceback (most recent call last): File "d:\python35\lib\site-packages\twisted\internet\defer.py", line 1128, in _inlineCallbacks result = g.send(result) File "d:\python35\lib\site-packages\scrapy\crawler.py", line 72, in crawl self.engine = self._create_engine() File "d:\python35\lib\site-packages\scrapy\crawler.py", line 97, in _create_engine return ExecutionEngine(self, lambda _: self.stop()) File "d:\python35\lib\site-packages\scrapy\core\engine.py", line 68, in __init__ self.downloader = downloader_cls(crawler) File "d:\python35\lib\site-packages\scrapy\core\downloader\__init__.py", line 88, in __init__ self.middleware = DownloaderMiddlewareManager.from_crawler(crawler) File "d:\python35\lib\site-packages\scrapy\middleware.py", line 58, in from_crawler return cls.from_settings(crawler.settings, crawler) File "d:\python35\lib\site-packages\scrapy\middleware.py", line 34, in from_settings mwcls = load_object(clspath) File "d:\python35\lib\site-packages\scrapy\utils\misc.py", line 44, in load_object mod = import_module(module) File "d:\python35\lib\importlib\__init__.py", line 126, in import_module return _bootstrap._gcd_import(name[level:], package, level) File " ", line 986, in _gcd_import File " ", line 969, in _find_and_load File " ", line 958, in _find_and_load_unlocked File " ", line 673, in _load_unlocked File " ", line 665, in exec_module File " ", line 222, in _call_with_frames_removed File "d:\python35\lib\site-packages\scrapy\downloadermiddlewares\retry.py", line 23, in from scrapy.xlib.tx import ResponseFailed File "d:\python35\lib\site-packages\scrapy\xlib\tx\__init__.py", line 3, in from twisted.web import client File "d:\python35\lib\site-packages\twisted\web\client.py", line 42, in from twisted.internet.endpoints import TCP4ClientEndpoint, SSL4ClientEndpoint File "d:\python35\lib\site-packages\twisted\internet\endpoints.py", line 34, in from twisted.internet.stdio import StandardIO, PipeAddress File "d:\python35\lib\site-packages\twisted\internet\stdio.py", line 30, in from twisted.internet import _win32stdio ImportError: cannot import name '_win32stdio' D:\python3\BR16>
解决方案:
solutions Scrapy can work with Python 3 on windows if you make some minor adjustments: Copy the _win32stdio and _pollingfile to the appropriate directory under site-packages. Namely, twisted-dir\internet. Download these fromhttps://github.com/twisted/twisted/tree/trunk/twisted/internet URLS: https://github.com/twisted/twisted/blob/trunk/src/twisted/internet/_win32stdio.py URLS: https://github.com/twisted/twisted/blob/trunk/src/twisted/internet/_pollingfile.py pip install pypiwin32 Granted, this is based on my personal experience. Because the repository will certainly change in the future, readers should beware the age of this answer. 来源: http://stackoverflow.com/questions/37342603/importerror-cannot-import-name-win32stdio