我是Scrapy的新手,只对python有基本的了解
运行Scrapy教程时遇到错误。
我安装了Windows 7操作系统,64位和32位Python 2.7.12
我到目前为止采取的步骤
scrapy startproject tutorial
quotes_spider.py
从scrapy \ Scripts \ tutorial我运行scrapy crawl quotes
并收到以下错误
(scrapy) F:\My Projects\scrapy\Scripts\tutorial>scrapy crawl quotes
2016-11-05 14:21:59 [scrapy] INFO: Scrapy 1.2.1 started (bot: tutorial)
2016-11-05 14:21:59 [scrapy] INFO: Overridden settings: {'NEWSPIDER_MODULE': 'tutorial.spiders', 'SPIDER_MODULES': ['tutorial.spiders'], 'ROBOTSTXT_OBEY': True, 'BOT_NAME': 'tutorial'}
2016-11-05 14:21:59 [scrapy] INFO: Enabled extensions:'scrapy.extensions.logstats.LogStats','scrapy.extensions.telnet.Telne tConsole', 'scrapy.extensions.corestats.CoreStats'] Unhandled error in Deferred:
2016-11-05 14:21:59 [twisted] CRITICAL: Unhandled error in Deferred:
2016-11-05 14:21:59 [twisted] CRITICAL:
Traceback (most recent call last):
File "f:\myproj~1\scrapy\lib\site-packages\twisted\internet\defer.py", line 12 60, in _inlineCallbacks result = g.send(result)
File "f:\myproj~1\scrapy\lib\site-packages\scrapy\crawler.py", line 90, in crawl six.reraise(*exc_info)
File "f:\myproj~1\scrapy\lib\site-packages\scrapy\crawler.py", line 72, in crawl self.engine = self._create_engine()
File "f:\myproj~1\scrapy\lib\site-packages\scrapy\crawler.py", line 97, in _create_engine return ExecutionEngine(self, lambda _: self.stop())
File "f:\myproj~1\scrapy\lib\site-packages\scrapy\core\engine.py", line 68, in __init__ self.downloader = downloader_cls(crawler)
File "f:\myproj~1\scrapy\lib\site- packages\scrapy\core\downloader\__init__.py"
, line 88, in __init__ self.middleware = DownloaderMiddlewareManager.from_crawler(crawler)
File "f:\myproj~1\scrapy\lib\site-packages\scrapy\middleware.py", line 58, in from_crawler return cls.from_settings(crawler.settings, crawler)
File "f:\myproj~1\scrapy\lib\site-packages\scrapy\middleware.py", line 34, in from_settings mwcls = load_object(clspath)
File "f:\myproj~1\scrapy\lib\site-packages\scrapy\utils\misc.py", line 44, in load_object mod = import_module(module)
File "c:\python27\Lib\importlib\__init__.py", line 37, in import_module__import__(name)
File "f:\myproj~1\scrapy\lib\site- packages\scrapy\downloadermiddlewares\retry.py", line 23, in <module> from scrapy.xlib.tx import ResponseFailed
File "f:\myproj~1\scrapy\lib\site-packages\scrapy\xlib\tx\__init__.py", line 3, in <module> from twisted.web import client
File "f:\myproj~1\scrapy\lib\site-packages\twisted\web\client.py", line 42, in <module> from twisted.internet.endpoints import TCP4ClientEndpoint, SSL4ClientEndpoint
File "f:\myproj~1\scrapy\lib\site-packages\twisted\internet\endpoints.py", line 36, in <module> from twisted.internet.stdio import StandardIO, PipeAddress
File "f:\myproj~1\scrapy\lib\site-packages\twisted\internet\stdio.py", line 30, in <module> from twisted.internet import _win32stdio
File "f:\myproj~1\scrapy\lib\site- packages\twisted\internet\_win32stdio.py", line 9, in <module> import win32api
ImportError: No module named win32api
这与所讨论的错误here非常相似,但建议的解决方案似乎没有成功。 pywin安装在我的全局环境C:Python27 \ Lib \ site-packages中,但它没有出现在我的虚拟环境中。我不确定如何在我的虚拟环境中安装它,因为pywin可执行文件似乎只允许在C下安装。提前感谢您的帮助!
我在虚拟环境中的点子列表是
ATTRS == 16.2.0
CFFI == 1.8.3
不断== 15.1.0
密码== 1.5.2
cssselect == 1.0.0
enum34 == 1.1.6
IDNA == 2.1
增量== 16.10.1
ip地址== 1.0.17
LXML == 3.6.4
parsel == 1.0.3
pyasn1 == 0.1.9
pyasn1模块== 0.0.8
pycparser == 2.17
PyDispatcher == 2.0.5
pyOpenSSL == 16.2.0
queuelib == 1.4.2
Scrapy == 1.2.1
服务身份== 16.0.0
6 == 1.10.0
扭曲的== 16.5.0
w3lib == 1.15.0
zope.interface == 4.3.2
答案 0 :(得分:2)
好像你错过了win32api,只需通过pip安装:
pip install pypiwin32