gpt4 book ai didi

python - 导入错误 : cannot import name replace_entities error when using Scrapy

转载 作者:可可西里 更新时间:2023-11-01 13:32:38 26 4
gpt4 key购买 nike

以前我会用scrapy写一个蜘蛛
scrapy startproject some_project

最近,我克隆了一个有蜘蛛的存储库,现在当我导航到正确的位置并输入scrapy crawl some_spider -o output.csv -t csv
我收到导入错误:

    Traceback (most recent call last):
File "/usr/local/bin/scrapy", line 3, in <module>
from scrapy.cmdline import execute
File "/usr/lib/pymodules/python2.7/scrapy/__init__.py", line 58, in <module>
from scrapy.selector import Selector
File "/usr/lib/pymodules/python2.7/scrapy/selector/__init__.py", line 4, in <module>
from scrapy.selector.unified import *
File "/usr/lib/pymodules/python2.7/scrapy/selector/unified.py", line 7, in <module>
from scrapy.utils.misc import extract_regex
File "/usr/lib/pymodules/python2.7/scrapy/utils/misc.py", line 8, in <module>
from w3lib.html import replace_entities
ImportError: cannot import name replace_entities

我四处搜索并试图查看“replace_entities”发生了什么,但我找不到任何信息。任何有关为什么会发生这些导入错误的帮助以及有关如何解决此问题的任何想法都将不胜感激。

最佳答案

w3libScrapy 的依赖,引用自setup.py (版本 0.24.4):

install_requires=[
'Twisted>=10.0.0',
'w3lib>=1.8.0',
'queuelib',
'lxml',
'pyOpenSSL',
'cssselect>=0.9',
'six>=1.5.2',
],

如您所见,Scrapy 要求 w3lib 为 1.8.0 或更高版本。

解决方案是升级w3lib包:

pip install --upgrade w3lib 

关于python - 导入错误 : cannot import name replace_entities error when using Scrapy,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26080706/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com