Python 找不到名为 service_identity 的模块

35 投票
1 回答
48892 浏览
提问于 2025-04-18 08:54

我尝试更新 scrapy(一个用来抓取网页的工具),但是在检查版本的时候遇到了以下错误:

C:\Windows\system32>scrapy version -v
:0: UserWarning: You do not have a working installation of the service_identity
module: 'No module named service_identity'.  Please install it from <https://pyp
i.python.org/pypi/service_identity> and make sure all of its dependencies are sa
tisfied.  Without the service_identity module and a recent enough pyOpenSSL to s
upport it, Twisted can perform only rudimentary TLS client hostname verification
.  Many valid certificate/hostname mappings may be rejected.
Scrapy  : 0.22.2
lxml    : 3.2.3.0
libxml2 : 2.9.0
Twisted : 14.0.0
Python  : 2.7 (r27:82525, Jul  4 2010, 09:01:59) [MSC v.1500 32 bit (Intel)]
Platform: Windows-7-6.1.7601-SP1

这是什么问题呢?我该怎么解决?

我使用的是 Windows 7 系统。

1 个回答

76
pip install service_identity

它在抱怨你没有 service_identity 这个东西。

关于这个模块的更多信息可以在 PyPI网站上找到


需要注意的是,这种情况比较少见,因为 service_identity 不是 twisted 这个包的必需品。它的开发者出于某种原因没有把它加到依赖列表里(可以参考 pyproject.toml),而是发出了 UserWarning,提醒缺少这个包,并需要手动来解决这个问题。

撰写回答