欢迎来到尧图网

客户服务 关于我们

您的位置:首页 > 新闻 > 国际 > [TypeError]: type ‘AbstractProvider‘ is not subscriptable

[TypeError]: type ‘AbstractProvider‘ is not subscriptable

2024/12/26 17:51:19 来源:https://blog.csdn.net/jaket5219999/article/details/143418523  浏览:    关键词:[TypeError]: type ‘AbstractProvider‘ is not subscriptable

升级pdm到2.20.0后,执行pdm add --dev mypy时报错了:

INFO: Adding group dev to lockfile
Adding packages to dev dev-dependencies: pytest, pdm, ruff, click, mypy
⠋ 0:00:00 Resolving dependencies
See /Users/mac10.12/Library/Logs/pdm/pdm-lock-aew5ui_n.log for detailed debug log.
[TypeError]: type 'AbstractProvider' is not subscriptable
WARNING: Add '-v' to see the detailed traceback

根据错误提示,打开/Users/mac10.12/Library/Logs/pdm/pdm-lock-aew5ui_n.log文件,发现报错的是:

pdm.termui: Error occurs
Traceback (most recent call last):File "/Users/mac10.12/.local/pipx/venvs/pdm/lib/python3.11/site-packages/pdm/termui.py", line 260, in loggingyield loggerFile "/Users/mac10.12/.local/pipx/venvs/pdm/lib/python3.11/site-packages/pdm/cli/actions.py", line 122, in do_lockresolver = resolver_class(^^^^^^^^^^^^^^^File "<string>", line 13, in __init__File "/Users/mac10.12/.local/pipx/venvs/pdm/lib/python3.11/site-packages/pdm/resolver/resolvelib.py", line 30, in __post_init__provider = self.project.get_provider(^^^^^^^^^^^^^^^^^^^^^^^^^^File "/Users/mac10.12/.local/pipx/venvs/pdm/lib/python3.11/site-packages/pdm/project/core.py", line 552, in get_providerfrom pdm.resolver.providers import get_providerFile "/Users/mac10.12/.local/pipx/venvs/pdm/lib/python3.11/site-packages/pdm/resolver/providers.py", line 49, in <module>class BaseProvider(AbstractProvider[Requirement, Candidate, str]):~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: type 'AbstractProvider' is not subscriptable

vi /Users/mac10.12/.local/pipx/venvs/pdm/lib/python3.11/site-packages/pdm/resolver/providers.py打开该文件,发现报错的是resolvelib库的AbstractProvider,猜测是该库没有升级到最新版导致的。

于是执行如下命令,升级该库,问题就解决了:

cd ~/.local/pipx/venvs/pdm # 注:我的pdm是用pipx安装的
source bin/activate
python -m pip install -U resolvelib
# Uninstalling resolvelib-1.0.1
# Successfully installed resolvelib-1.1.0
deactivate
cd -
pdm add --dev ruff

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com