文档读取失败,并显示“无法从'pip._internal.index'导入名称'PackageFinder'”


25

Sphinx文档在read-the-docs上的构建失败,并显示以下错误(以下完整日志):

ImportError: cannot import name 'PackageFinder' from 'pip._internal.index' (/home/docs/checkouts/readthedocs.org/user_builds/cascade-python/envs/latest/lib/python3.7/site-packages/pip/_internal/index/__init__.py)

我做错什么了吗?或者这是阅读文档中的错误?

Sphinx文档的本地版本运行良好。

阅读文档时完整的错误日志:

Read the Docs build information
Build id: 10299638
Project: cascade-python
Version: latest
Commit: a7d50bf781bd8076b10dd7024db4ccb628016c27
Date: 2020-01-21T17:03:12.876711Z
State: finished
Success: False


[rtd-command-info] start-time: 2020-01-21T17:03:13.203354Z, end-time: 2020-01-21T17:03:13.215400Z, duration: 0, exit-code: 0
git remote set-url origin https://github.com/brunorijsman/cascade-python.git


[rtd-command-info] start-time: 2020-01-21T17:03:13.276220Z, end-time: 2020-01-21T17:03:13.630658Z, duration: 0, exit-code: 0
git fetch origin --force --tags --prune --prune-tags --depth 50
From https://github.com/brunorijsman/cascade-python
   2a28505..a7d50bf  master     -> origin/master

[rtd-command-info] start-time: 2020-01-21T17:03:13.824496Z, end-time: 2020-01-21T17:03:13.876904Z, duration: 0, exit-code: 0
git checkout --force origin/master
Previous HEAD position was 2a28505 Fix lint
HEAD is now at a7d50bf Trigger docs build

[rtd-command-info] start-time: 2020-01-21T17:03:13.941290Z, end-time: 2020-01-21T17:03:13.951085Z, duration: 0, exit-code: 0
git clean -d -f -f


[rtd-command-info] start-time: 2020-01-21T17:03:16.657644Z, end-time: 2020-01-21T17:03:22.489740Z, duration: 5, exit-code: 0
python3.7 -mvirtualenv --no-site-packages --no-download /home/docs/checkouts/readthedocs.org/user_builds/cascade-python/envs/latest
Using base prefix '/home/docs/.pyenv/versions/3.7.3'
New python executable in /home/docs/checkouts/readthedocs.org/user_builds/cascade-python/envs/latest/bin/python3.7
Not overwriting existing python script /home/docs/checkouts/readthedocs.org/user_builds/cascade-python/envs/latest/bin/python (you must use /home/docs/checkouts/readthedocs.org/user_builds/cascade-python/envs/latest/bin/python3.7)
Installing setuptools, pip, wheel...
done.

[rtd-command-info] start-time: 2020-01-21T17:03:22.562608Z, end-time: 2020-01-21T17:03:23.258281Z, duration: 0, exit-code: 1
/home/docs/checkouts/readthedocs.org/user_builds/cascade-python/envs/latest/bin/python -m pip install --upgrade --cache-dir /home/docs/checkouts/readthedocs.org/user_builds/cascade-python/.cache/pip pip
Traceback (most recent call last):
  File "/home/docs/.pyenv/versions/3.7.3/lib/python3.7/runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "/home/docs/.pyenv/versions/3.7.3/lib/python3.7/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/home/docs/checkouts/readthedocs.org/user_builds/cascade-python/envs/latest/lib/python3.7/site-packages/pip/__main__.py", line 16, in <module>
    from pip._internal import main as _main  # isort:skip # noqa
  File "/home/docs/checkouts/readthedocs.org/user_builds/cascade-python/envs/latest/lib/python3.7/site-packages/pip/_internal/__init__.py", line 40, in <module>
    from pip._internal.cli.autocompletion import autocomplete
  File "/home/docs/checkouts/readthedocs.org/user_builds/cascade-python/envs/latest/lib/python3.7/site-packages/pip/_internal/cli/autocompletion.py", line 8, in <module>
    from pip._internal.cli.main_parser import create_main_parser
  File "/home/docs/checkouts/readthedocs.org/user_builds/cascade-python/envs/latest/lib/python3.7/site-packages/pip/_internal/cli/main_parser.py", line 12, in <module>
    from pip._internal.commands import (
  File "/home/docs/checkouts/readthedocs.org/user_builds/cascade-python/envs/latest/lib/python3.7/site-packages/pip/_internal/commands/__init__.py", line 6, in <module>
    from pip._internal.commands.completion import CompletionCommand
  File "/home/docs/checkouts/readthedocs.org/user_builds/cascade-python/envs/latest/lib/python3.7/site-packages/pip/_internal/commands/completion.py", line 6, in <module>
    from pip._internal.cli.base_command import Command
  File "/home/docs/checkouts/readthedocs.org/user_builds/cascade-python/envs/latest/lib/python3.7/site-packages/pip/_internal/cli/base_command.py", line 25, in <module>
    from pip._internal.index import PackageFinder
ImportError: cannot import name 'PackageFinder' from 'pip._internal.index' (/home/docs/checkouts/readthedocs.org/user_builds/cascade-python/envs/latest/lib/python3.7/site-packages/pip/_internal/index/__init__.py)

您是最后一天遇到相同导入错误的第二个人。我建议向RTD提交一个问题,提到刚刚发布了pip 20.0.0,紧接着是一个修补程序20.0.1,这可能是相关的。我也会提出pip问题。
Steve Piercy

@StevePiercy在RTD github存储库上记录了一个问题。
Bruno Rijsman

Answers:


27

该问题和修复在文档阅读问题#6554(https://github.com/readthedocs/readthedocs.org/issues/6554)中进行了描述:

当前,所有构建都失败了,因为自动升级(自#4823以来)到pip 20.0的过程存在问题(请参阅pypa / pip#7620)。现在有一个20.0.1版本,似乎已经解决了其他人的问题……但是我怎么能迫使我的readthedocs也升级到.1版本?

解决方法是按如下所述清除构建环境(这取自https://docs.readthedocs.io/en/stable/guides/wipe-environment.html):

  • 登录以阅读文档
  • 前往版本
  • 单击页面右侧要擦除的版本的“编辑”按钮
  • 转到页面底部,然后单击“保存”按钮旁边的擦除链接
  • 现在,您可以使用全新的构建环境来重新构建版本!

此修复程序对我有用(但是从2020年1月26日起,您必须为每个构建版本消除环境-请参阅下面的Grimmy的评论)。


2
现在,仅适用于单个构建。他们将在下周部署修补程序。如果您的构建失败,请直到那时擦拭环境
Grimmy
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.