Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build Failed. TypeError: 'generator' object is not subscriptable #8616

Closed
GilimkhanovDenis opened this issue Oct 26, 2021 · 22 comments
Closed
Labels
Support Support question

Comments

@GilimkhanovDenis
Copy link

GilimkhanovDenis commented Oct 26, 2021

Update from @astrojuanlu: see this comment for a workaround for this issue, our blog for a more detailed explanation, and this comment for current status of this issue


Success Build: https://readthedocs.org/projects/diadocsdk-1c/builds/15092197/
Failed Build: https://readthedocs.org/projects/diadocsdk-1c/builds/15095749/

It's the same commit

What is changed during 8 hours ?
What can I do for successful build?

building [html]: targets for 402 source files that are out of date
updating environment: 402 added, 0 changed, 0 removed
reading sources... [  0%] ComObjects/AcceptanceCertificateBuyerContent
reading sources... [  0%] ComObjects/AcceptanceCertificateContent
reading sources... [  0%] ComObjects/AcceptanceCertificateItem
reading sources... [  0%] ComObjects/AcceptanceCertificateSellerContent

Traceback (most recent call last):
  File "/home/docs/checkouts/readthedocs.org/user_builds/diadocsdk-1c/envs/dev/lib/python3.7/site-packages/sphinx/cmd/build.py", line 304, in build_main
    app.build(args.force_all, filenames)
  File "/home/docs/checkouts/readthedocs.org/user_builds/diadocsdk-1c/envs/dev/lib/python3.7/site-packages/sphinx/application.py", line 341, in build
    self.builder.build_update()
  File "/home/docs/checkouts/readthedocs.org/user_builds/diadocsdk-1c/envs/dev/lib/python3.7/site-packages/sphinx/builders/__init__.py", line 347, in build_update
    len(to_build))
  File "/home/docs/checkouts/readthedocs.org/user_builds/diadocsdk-1c/envs/dev/lib/python3.7/site-packages/sphinx/builders/__init__.py", line 360, in build
    updated_docnames = set(self.read())
  File "/home/docs/checkouts/readthedocs.org/user_builds/diadocsdk-1c/envs/dev/lib/python3.7/site-packages/sphinx/builders/__init__.py", line 468, in read
    self._read_serial(docnames)
  File "/home/docs/checkouts/readthedocs.org/user_builds/diadocsdk-1c/envs/dev/lib/python3.7/site-packages/sphinx/builders/__init__.py", line 490, in _read_serial
    self.read_doc(docname)
  File "/home/docs/checkouts/readthedocs.org/user_builds/diadocsdk-1c/envs/dev/lib/python3.7/site-packages/sphinx/builders/__init__.py", line 534, in read_doc
    doctree = read_doc(self.app, self.env, self.env.doc2path(docname))
  File "/home/docs/checkouts/readthedocs.org/user_builds/diadocsdk-1c/envs/dev/lib/python3.7/site-packages/sphinx/io.py", line 318, in read_doc
    pub.publish()
  File "/home/docs/checkouts/readthedocs.org/user_builds/diadocsdk-1c/envs/dev/lib/python3.7/site-packages/docutils/core.py", line 219, in publish
    self.apply_transforms()
  File "/home/docs/checkouts/readthedocs.org/user_builds/diadocsdk-1c/envs/dev/lib/python3.7/site-packages/docutils/core.py", line 200, in apply_transforms
    self.document.transformer.apply_transforms()
  File "/home/docs/checkouts/readthedocs.org/user_builds/diadocsdk-1c/envs/dev/lib/python3.7/site-packages/sphinx/transforms/__init__.py", line 90, in apply_transforms
    Transformer.apply_transforms(self)
  File "/home/docs/checkouts/readthedocs.org/user_builds/diadocsdk-1c/envs/dev/lib/python3.7/site-packages/docutils/transforms/__init__.py", line 171, in apply_transforms
    transform.apply(**kwargs)
  File "/home/docs/checkouts/readthedocs.org/user_builds/diadocsdk-1c/envs/dev/lib/python3.7/site-packages/sphinx/transforms/references.py", line 38, in apply
    domain.process_doc(self.env, self.env.docname, self.document)
  File "/home/docs/checkouts/readthedocs.org/user_builds/diadocsdk-1c/envs/dev/lib/python3.7/site-packages/sphinx/domains/std.py", line 586, in process_doc
    self.note_labels(env, docname, document)
  File "/home/docs/checkouts/readthedocs.org/user_builds/diadocsdk-1c/envs/dev/lib/python3.7/site-packages/sphinx/domains/std.py", line 638, in note_labels
    n = node.traverse(addnodes.toctree)[0]
TypeError: 'generator' object is not subscriptable

Exception occurred:
  File "/home/docs/checkouts/readthedocs.org/user_builds/diadocsdk-1c/envs/dev/lib/python3.7/site-packages/sphinx/domains/std.py", line 638, in note_labels
    n = node.traverse(addnodes.toctree)[0]
TypeError: 'generator' object is not subscriptable
@humitos
Copy link
Member

humitos commented Oct 26, 2021

The version of docutils is not pinned and a new version was released.

The build that passed installed docutils-0.17.1-py2.py3-none-any.whl and the one that failed, installed docutils-0.18-py2.py3-none-any.whl

@humitos humitos added the Support Support question label Oct 26, 2021
@GilimkhanovDenis
Copy link
Author

@humitos thank you

@astrojuanlu
Copy link
Contributor

astrojuanlu commented Oct 26, 2021

For future readers, the solution for this problem is to pin docutils<0.18 in your requirements.txt file, and have a .readthedocs.yaml file with these contents:

version: 2

python:
   install:
   - requirements: docs/requirements.txt

More information in our docs. See also our page on reproducible builds to better understand how to use requirements files on Read the Docs.

BrianJKoopman added a commit to simonsobs/socs that referenced this issue Oct 26, 2021
A recent update in docutils breaks builds on readthedocs. This is the suggested
work around from readthedocs [1].

[1] - readthedocs/readthedocs.org#8616
adswa added a commit to datalad/datalad-osf that referenced this issue Oct 27, 2021
adswa added a commit to datalad-handbook/book that referenced this issue Oct 27, 2021
@astrojuanlu
Copy link
Contributor

Great summary originally posted by @joshuacwnewton in sphinx-doc/sphinx#9783 (comment):

We've run into this issue too for several projects. Here's a summary of the problem:

The solution we settled on was to make sure we explicitly specified a more recent version of Sphinx in our RTD requirements. Please refer to RTD's "Reproducible Builds" page (and specifically the pinning dependencies section) for more information on RTD's recommendations here.

@joshuacwnewton
Copy link

joshuacwnewton commented Oct 27, 2021

Quick addendum:

  • If your project pins the version of sphinx using extras_require keyword in your setup.py, and
  • In RTD you're installing your project via the python keyword of your .readthedocs.yaml config file

Then you can also fix the problem by making sure you set extra_requirements in your RTD config file.

I've seen this trip up projects where folks were already pinning Sphinx, only to find out that RTD wasn't picking up those extra requirements.

davidbeckingsale added a commit to LLNL/Umpire that referenced this issue Oct 27, 2021
Fix issue where Sphinx doesn't work with docutils 0.18 by specifying a
version constraint in docs/requirements.txt. More details:
readthedocs/readthedocs.org#8616
davidbeckingsale added a commit to LLNL/Umpire that referenced this issue Oct 27, 2021
Fix issue where Sphinx doesn't work with docutils 0.18 by specifying a
version constraint in docs/requirements.txt. More details:
readthedocs/readthedocs.org#8616
@rstoneback rstoneback mentioned this issue Oct 27, 2021
16 tasks
BrianJKoopman added a commit to simonsobs/socs that referenced this issue Oct 27, 2021
A recent update in docutils breaks builds on readthedocs. This is the suggested
work around from readthedocs [1].

[1] - readthedocs/readthedocs.org#8616
wol-soft added a commit to wol-soft/php-json-schema-model-generator that referenced this issue Nov 11, 2021
atrisovic added a commit to atrisovic/pyDataverse that referenced this issue Nov 11, 2021
zuo added a commit to zuo/unittest_expander that referenced this issue Nov 12, 2021
philipstarkey added a commit to philipstarkey/monashspa that referenced this issue Nov 13, 2021
markwj added a commit to openvehicles/Open-Vehicle-Monitoring-System-3 that referenced this issue Nov 15, 2021
Mayitzin added a commit to Mayitzin/ahrs that referenced this issue Nov 18, 2021
The newest version of docutils clashes with the built system in readthedocs. An older version is required for it to work. See readthedocs/readthedocs.org#8616
@astrojuanlu
Copy link
Contributor

Update: Sphinx 1.8.6 was released this week, and it pins docutils to <0.18 (thanks @tk0miya ❤️)

However, users of old pip versions (for example on Python 2) might not benefit from this, and will need to pin docutils themselves anyway. Otherwise, they will still observe the error, plus this warning on the logs:

ERROR: pip's legacy dependency resolver does not consider dependency conflicts when selecting packages. This behaviour is the source of the following dependency conflicts.
sphinx 1.8.6 requires docutils<0.18,>=0.11, but you'll have docutils 0.18 which is incompatible.

@gmilde
Copy link

gmilde commented Nov 20, 2021 via email

@astrojuanlu
Copy link
Contributor

Thanks @gmilde , looking into this 👍🏽

@astrojuanlu
Copy link
Contributor

@gmilde I confirm that docutils 0.18.1b1 does not exhibit the 'generator' object has no attribute '__getitem__' (or variations of it) anymore 👍🏽

I was testing with a fork of the project where I originally detected this. I may delete the project at any time.

Amending diff: astrojuanlu/phpunit-documentation-english@968e3d2

duartegalvao pushed a commit to duartegalvao/indico that referenced this issue Dec 6, 2021
duartegalvao pushed a commit to duartegalvao/indico that referenced this issue Dec 7, 2021
Jakob-Lass added a commit to MJOLNIRPackage/MJOLNIR that referenced this issue Dec 15, 2021
Add readthedocs.yaml
Add requirements with docutils<0.18 (described in
 readthedocs/readthedocs.org#8616)
@astrojuanlu astrojuanlu unpinned this issue Dec 21, 2021
dawson6 pushed a commit to LLNL/ATS that referenced this issue Feb 17, 2022
* link docs and add badge to readme

* add workaround for docutils problem readthedocs/readthedocs.org#8616

* update copyright

* move toc to intro page

* delete old index before moving intro in its place

* move intro into index's place

* fix path

* fix another path
0xtobit pushed a commit to braintree/braintree_python that referenced this issue Apr 19, 2022
zuo added a commit to zuo/unittest_expander that referenced this issue Mar 18, 2023
...as pinning `docutils<0.18` seems no longer necessary (see:
readthedocs/readthedocs.org#8616).
jarrodchesney pushed a commit to Synerty/synerty-peek that referenced this issue Nov 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Support Support question
Projects
None yet
Development

No branches or pull requests

9 participants