Readthedocs.org: `ModuleNotFoundError: No module named 'six'` on build

Created on 28 Nov 2020  路  15Comments  路  Source: readthedocs/readthedocs.org

Details

I tried building my docs for my project, yet this fails with a ModuleNotFoundError

My conf file
Build url

Expected Result

A successful build

Actual Result

The following error:

Running Sphinx v3.3.1

Traceback (most recent call last):
  File "/home/docs/checkouts/readthedocs.org/user_builds/dblstats/envs/latest/lib/python3.7/site-packages/sphinx/config.py", line 319, in eval_config_file
    execfile_(filename, namespace)
  File "/home/docs/checkouts/readthedocs.org/user_builds/dblstats/envs/latest/lib/python3.7/site-packages/sphinx/util/pycompat.py", line 89, in execfile_
    exec(code, _globals)
  File "/home/docs/checkouts/readthedocs.org/user_builds/dblstats/checkouts/latest/docs/source/conf.py", line 82, in <module>
    from six import string_types
ModuleNotFoundError: No module named 'six'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/home/docs/checkouts/readthedocs.org/user_builds/dblstats/envs/latest/lib/python3.7/site-packages/sphinx/cmd/build.py", line 279, in build_main
    args.tags, args.verbosity, args.jobs, args.keep_going)
  File "/home/docs/checkouts/readthedocs.org/user_builds/dblstats/envs/latest/lib/python3.7/site-packages/sphinx/application.py", line 219, in __init__
    self.config = Config.read(self.confdir, confoverrides or {}, self.tags)
  File "/home/docs/checkouts/readthedocs.org/user_builds/dblstats/envs/latest/lib/python3.7/site-packages/sphinx/config.py", line 174, in read
    namespace = eval_config_file(filename, tags)
  File "/home/docs/checkouts/readthedocs.org/user_builds/dblstats/envs/latest/lib/python3.7/site-packages/sphinx/config.py", line 332, in eval_config_file
    raise ConfigError(msg % traceback.format_exc()) from exc
sphinx.errors.ConfigError: There is a programmable error in your configuration file:

Traceback (most recent call last):
  File "/home/docs/checkouts/readthedocs.org/user_builds/dblstats/envs/latest/lib/python3.7/site-packages/sphinx/config.py", line 319, in eval_config_file
    execfile_(filename, namespace)
  File "/home/docs/checkouts/readthedocs.org/user_builds/dblstats/envs/latest/lib/python3.7/site-packages/sphinx/util/pycompat.py", line 89, in execfile_
    exec(code, _globals)
  File "/home/docs/checkouts/readthedocs.org/user_builds/dblstats/checkouts/latest/docs/source/conf.py", line 82, in <module>
    from six import string_types
ModuleNotFoundError: No module named 'six'


Configuration error:
There is a programmable error in your configuration file:

Traceback (most recent call last):
  File "/home/docs/checkouts/readthedocs.org/user_builds/dblstats/envs/latest/lib/python3.7/site-packages/sphinx/config.py", line 319, in eval_config_file
    execfile_(filename, namespace)
  File "/home/docs/checkouts/readthedocs.org/user_builds/dblstats/envs/latest/lib/python3.7/site-packages/sphinx/util/pycompat.py", line 89, in execfile_
    exec(code, _globals)
  File "/home/docs/checkouts/readthedocs.org/user_builds/dblstats/checkouts/latest/docs/source/conf.py", line 82, in <module>
    from six import string_types
ModuleNotFoundError: No module named 'six'
Accepted Bug

Most helpful comment

Hi, I had the same issue. At first, I followed the recommendation https://github.com/readthedocs/readthedocs.org/issues/7704#issuecomment-735030431 but it was not complete without specifying requirements in the settings.

Solved

Here is how I solved it, first follow https://github.com/readthedocs/readthedocs.org/issues/7704#issuecomment-735030431, and then click Admin, Advanced Settings and then under the section Requirements file add the file path you created docs/requirements.txt. Click on Save and build Version. I hope this works out for you.

Cheers.

All 15 comments

Same issue. I tried to recompile a version that were successfully compiled yesterday, and it failed, so it is not related to my sources.

Same error. I wanted to try this tool today for the first time. What bad luck !!! Red alert devs.

Hi, I had the same issue. At first, I followed the recommendation https://github.com/readthedocs/readthedocs.org/issues/7704#issuecomment-735030431 but it was not complete without specifying requirements in the settings.

Solved

Here is how I solved it, first follow https://github.com/readthedocs/readthedocs.org/issues/7704#issuecomment-735030431, and then click Admin, Advanced Settings and then under the section Requirements file add the file path you created docs/requirements.txt. Click on Save and build Version. I hope this works out for you.

Cheers.

This is not a solution.
RTD must work on a simple configuration without declaring any external dependency, and recompiling previous builds must work.

@ynerant, agreed. If I am not wrong, Package six needs to be installed on the RTD's end. If it's not already there, we need to specify that in the requirements. This fixed the problem I had, but hopefully, the dev team comes up with a better alternative.

I tried the above solution but it did not work for me...

I tried the above solution but it did not work for me...

@Jonas231 it didn't for me either in the beginning, but when migrating the items from the source folder into the docs folder it did work.

@ynerant, agreed. If I am not wrong, Package six needs to be installed on the RTD's end. If it's not already there, we need to specify that in the requirements. This fixed the problem I had, but hopefully, the dev team comes up with a better alternative.

I agree, I'll keep this issue open until its fixed.

Yep, that's an issue, docs start failing to build without any changes to their configuration.

I tried the above solution but it did not work for me...

@Jonas231, the filename mentioned in .yml file is different than what you have in the docs folder. I see it is commented for now.

Also, the way you did make html to generate HTML files, you should make clean to clean the build folder before you commit on GitHub. Let me know if this works.

I'm not sure why this started failing now. However, we are appending some extra logic to the user's conf.py file and this logic relies on six but we are not installing it as a "core requirements" together with the others.

I just did a quick test creating an empty virtualenv and installing our core requirements:

$ python -m pip install --upgrade --no-cache-dir setuptools==41.0.1 docutils==0.14 mock==1.0.1 pillow==5.4.1 'alabaster>=0.7,<0.8,!=0.7.5' commonmark==0.8.1 recommonmark==0.5.0 sphinx sphinx-rtd-theme 'readthedocs-sphinx-ext<2.2'

...

$ python
Python 3.7.7 (default, Apr 11 2020, 22:03:50) 
[GCC 9.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import six
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'six'
>>>

None of them installed six as a dependency. So, we should

  • include it as a "core dependency"
  • remove its usage (is seems we only use it to check for string_types)

We will have a patch for this soon.

As a workaround while we create the patch and deploy it, you can:

  1. create a requirements.txt file and add six to it
  2. use the readthedocs.yml config file to install those requirements (https://docs.readthedocs.io/en/stable/config-file/v2.html#python)

Hi all! I deployed a quick fix for now that does not install latest sphinx version by default (3.3.1) but the previous one that Read the Docs pinned for years (1.8.x).

We enabled this feature (USE_LATEST_SPHINX for new projects) to start testing the builder with this new version of Sphinx, but we didn't realize that six was not a dependency anymore. So, for now, I disabled this feature and your builds will use sphinx==1.8.x by default. If you want to use a different version of Sphinx, please specify it in your requirements.txt file as usual.

We will have a fix for this soon and we will re-enable USE_LATEST_SPHINX version for new projects.

@humitos is USE_LATEST_SPHINX for new projects only and not existing projects, and if so what is a "new" project? I did not see it documented. I also did not see it in any release notes. USE_LATEST_SPHINX is only mentioned in this issue and its related PR, and an old issue.

@stevepiercy "new projects" currently means "project created after Oct 20" (*) which is when this feature was added/enabled. We do not document this feature flag because is only for internal usage. As it's hard to upgrade a pinned core dependency without breaking everyone's builds we have this kind of features that we can easily enable or disable for a set of projects to start testing out how the upgrade of this dependency will behave and can rollback fast if something goes wrong.

(*) this is relative to each feature flag and we could update this date manually again depending on the new feature we want to test.

Was this page helpful?
0 / 5 - 0 ratings