Read-the-docs build fails with “cannot import name ‘PackageFinder’ from ‘pip._internal.index'”

Each Answer to this Q is separated by one/two green lines.

The build of Sphinx docs on read-the-docs fails with the following error (complete log below):

ImportError: cannot import name 'PackageFinder' from 'pip._internal.index' (/home/docs/checkouts/

Did I do something wrong or is this a bug in read-the-docs?

A local build of Sphinx docs runs fine.

Complete error log on read-the-docs:

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

[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
   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/
Using base prefix '/home/docs/.pyenv/versions/3.7.3'
New python executable in /home/docs/checkouts/
Not overwriting existing python script /home/docs/checkouts/ (you must use /home/docs/checkouts/
Installing setuptools, pip, wheel...

[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/ -m pip install --upgrade --cache-dir /home/docs/checkouts/ pip
Traceback (most recent call last):
  File "/home/docs/.pyenv/versions/3.7.3/lib/python3.7/", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "/home/docs/.pyenv/versions/3.7.3/lib/python3.7/", line 85, in _run_code
    exec(code, run_globals)
  File "/home/docs/checkouts/", line 16, in <module>
    from pip._internal import main as _main  # isort:skip # noqa
  File "/home/docs/checkouts/", line 40, in <module>
    from pip._internal.cli.autocompletion import autocomplete
  File "/home/docs/checkouts/", line 8, in <module>
    from pip._internal.cli.main_parser import create_main_parser
  File "/home/docs/checkouts/", line 12, in <module>
    from pip._internal.commands import (
  File "/home/docs/checkouts/", line 6, in <module>
    from pip._internal.commands.completion import CompletionCommand
  File "/home/docs/checkouts/", line 6, in <module>
    from pip._internal.cli.base_command import Command
  File "/home/docs/checkouts/", line 25, in <module>
    from pip._internal.index import PackageFinder
ImportError: cannot import name 'PackageFinder' from 'pip._internal.index' (/home/docs/checkouts/

The issue and the fix are described in read-the-docs issue #6554 (

Currently all builds are failing because the automatic upgrade (since #4823 ) to pip 20.0 was buggy (see pypa/pip#7620 ). There’s now a 20.0.1 release which seems to have fixed the problem for others … but how can I force my readthedocs to also upgrade to the .1 version?

The fix is to wipe out the build environment as follows (this is taken from

  • Log in to read-the-docs
  • Go to Versions
  • Click on the Edit button of the version you want to wipe on the right side of the page
  • Go to the bottom of the page and click the wipe link, next to the “Save” button
  • Now you can re-build the version with a fresh build environment!

This fix worked for me (but as of 26-Jan-2020 you have to wipe out the environment for every build — see comment from Grimmy below).

The answers/resolutions are collected from stackoverflow, are licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0 .