【发布时间】:2023-02-26 05:40:48
【问题描述】:
根据它的文档,Scrapy 将使用 ipython 如果它已经安装在用户的系统中。是否可以安装 ipython 但仍然通过在 scrapy.cfg 中指定 shell 字段来指示 Scrapy 使用默认的 python shell?
目前,无论我在该字段中指定什么,Scrapy 都使用 ipython(即使它被省略)
【问题讨论】:
标签: python web-scraping scrapy
根据它的文档,Scrapy 将使用 ipython 如果它已经安装在用户的系统中。是否可以安装 ipython 但仍然通过在 scrapy.cfg 中指定 shell 字段来指示 Scrapy 使用默认的 python shell?
目前,无论我在该字段中指定什么,Scrapy 都使用 ipython(即使它被省略)
【问题讨论】:
标签: python web-scraping scrapy
根据 scrapy 文档:
通过 Scrapy 的设置,您可以将其配置为使用 ipython、bpython 或标准 python shell 中的任何一个,无论安装了哪个。这是通过设置 SCRAPY_PYTHON_SHELL 环境变量来完成的;或者在你的 scrapy.cfg 中定义它:
默认的
scrapy.cfg如下所示:# Automatically created by: scrapy startproject # # For more information about the [deploy] section see: # https://scrapyd.readthedocs.io/en/latest/deploy.html [settings] default = projectname.settings [deploy] #url = http://localhost:6800/ project = projectname因此,为了指定要使用的 shell,您需要将其添加到
settings标头下,如下所示。# Automatically created by: scrapy startproject # # For more information about the [deploy] section see: # https://scrapyd.readthedocs.io/en/latest/deploy.html [settings] default = projectname.settings shell = python [deploy] #url = http://localhost:6800/ project = projectname我已经测试并确认这有效并且确实使用了标准的 python shell,即使我在同一环境中安装了 ipython。
【讨论】: