Scrapy已安装但无法运行工作台或外壳

时间:2018-02-19 21:51:55

标签: python scrapy

我终于安装了scrapy但是无法让它运行工作台或shell。 这是在控制台中返回的内容:

(scrapy_env) MacBook-Pro:Virtualenvs iSagui$ scrapy bench
2018-02-19 14:46:26 [scrapy.utils.log] INFO: Scrapy 1.5.0 started (bot: scrapybot)
2018-02-19 14:46:26 [scrapy.utils.log] INFO: Versions: lxml 3.4.2.0, libxml2 2.9.4, cssselect 1.0.3, parsel 1.4.0, w3lib 1.19.0, Twisted 17.9.0, Python 3.7.0a2 (v3.7.0a2:f7ac4fe52a, Oct 16 2017, 21:11:18) - [GCC 4.2.1 (Apple Inc. build 5666) (dot 3)], pyOpenSSL 17.5.0 (OpenSSL 1.0.2n  7 Dec 2017), cryptography 2.1.4, Platform Darwin-17.4.0-x86_64-i386-64bit
2018-02-19 14:46:27 [scrapy.crawler] INFO: Overridden settings: {'CLOSESPIDER_TIMEOUT': 10, 'LOGSTATS_INTERVAL': 1, 'LOG_LEVEL': 'INFO'}
Traceback (most recent call last):
  File "/Users/iSagui/Virtualenvs/scrapy_env/bin/scrapy", line 11, in <module>
    sys.exit(execute())
  File "/Users/iSagui/Virtualenvs/scrapy_env/lib/python3.7/site-packages/scrapy/cmdline.py", line 150, in execute
    _run_print_help(parser, _run_command, cmd, args, opts)
  File "/Users/iSagui/Virtualenvs/scrapy_env/lib/python3.7/site-packages/scrapy/cmdline.py", line 90, in _run_print_help
    func(*a, **kw)
  File "/Users/iSagui/Virtualenvs/scrapy_env/lib/python3.7/site-packages/scrapy/cmdline.py", line 157, in _run_command
    cmd.run(args, opts)
  File "/Users/iSagui/Virtualenvs/scrapy_env/lib/python3.7/site-packages/scrapy/commands/bench.py", line 25, in run
    self.crawler_process.crawl(_BenchSpider, total=100000)
  File "/Users/iSagui/Virtualenvs/scrapy_env/lib/python3.7/site-packages/scrapy/crawler.py", line 170, in crawl
    crawler = self.create_crawler(crawler_or_spidercls)
  File "/Users/iSagui/Virtualenvs/scrapy_env/lib/python3.7/site-packages/scrapy/crawler.py", line 198, in create_crawler
    return self._create_crawler(crawler_or_spidercls)
  File "/Users/iSagui/Virtualenvs/scrapy_env/lib/python3.7/site-packages/scrapy/crawler.py", line 203, in _create_crawler
    return Crawler(spidercls, self.settings)
  File "/Users/iSagui/Virtualenvs/scrapy_env/lib/python3.7/site-packages/scrapy/crawler.py", line 55, in __init__
    self.extensions = ExtensionManager.from_crawler(self)
  File "/Users/iSagui/Virtualenvs/scrapy_env/lib/python3.7/site-packages/scrapy/middleware.py", line 58, in from_crawler
    return cls.from_settings(crawler.settings, crawler)
  File "/Users/iSagui/Virtualenvs/scrapy_env/lib/python3.7/site-packages/scrapy/middleware.py", line 34, in from_settings
    mwcls = load_object(clspath)
  File "/Users/iSagui/Virtualenvs/scrapy_env/lib/python3.7/site-packages/scrapy/utils/misc.py", line 44, in load_object
    mod = import_module(module)
  File "/Users/iSagui/Virtualenvs/scrapy_env/lib/python3.7/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 994, in _gcd_import
  File "<frozen importlib._bootstrap>", line 971, in _find_and_load
  File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 680, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/Users/iSagui/Virtualenvs/scrapy_env/lib/python3.7/site-packages/scrapy/extensions/telnet.py", line 12, in <module>
    from twisted.conch import manhole, telnet
  File "/Users/iSagui/Virtualenvs/scrapy_env/lib/python3.7/site-packages/twisted/conch/manhole.py", line 154
    def write(self, data, async=False):
                              ^
SyntaxError: invalid syntax
(scrapy_env) MacBook-Pro:Virtualenvs iSagui$ 

我已经彻底消灭了虚拟环境并重新安装了同样的问题。

以下是我对scrapy的看法:

scrapy version -v
Scrapy       : 1.5.0
lxml         : 3.4.2.0
libxml2      : 2.9.4
cssselect    : 1.0.3
parsel       : 1.4.0
w3lib        : 1.19.0
Twisted      : 17.9.0
Python       : 3.7.0a2 (v3.7.0a2:f7ac4fe52a, Oct 16 2017, 21:11:18) - [GCC 4.2.1 (Apple Inc. build 5666) (dot 3)]
pyOpenSSL    : 17.5.0 (OpenSSL 1.0.2n  7 Dec 2017)
cryptography : 2.1.4
Platform     : Darwin-17.4.0-x86_64-i386-64bit

感谢您的帮助!

1 个答案:

答案 0 :(得分:0)

在python 3.7中,asyncawait成为关键字,使该语法无效。

PEP 492中提到了这一点,但我在#34;新的&#34;中没有看到任何引用。 doc for python 3.7

似乎扭曲还没有支持python 3.7