Tutor Build issue: AttributeError: module 'mistune' has no attribute 'BlockGrammar'

Hey all/anyone,
to start system specs:

  • Tutor v14.0.4
  • Ubuntu 20.04
  • python 3.8.10
  • running a custom edx-platform fork, branched from open-release/nutmeg.1 (with only minor changes seemingly unrelated to the issue, url.py changes and modifying default xblocks)

I’m having an issue with REbuilding the edx-platform in the latest version of Tutor 14.0.4

sorry for the story time, but I need to outline what may have changed prior to breakage:


I’ve updated our system from a koa version after some trial and error and managed to get it building and running successfully with my custom fork of open-release/nutmeg.1.
Updated plugins, updated theme, updated source code, etc.
and have had the system running successfully with our custom fork for roughly a week.

Today I’ve implemented a very minor modification to our theme (just modified a link address in the header, essentially just a raw text change)
and i cannot get the system to build again. to rule out some things

  • I’ve reverted the theme modification to rule out it being the issue
  • our custom fork was building previously, with no modification since
  • i’ve even attempted building without the custom fork and including --no-cache to rule out that as the issue


Consistently, I’m getting the following error on step 96 when building the openedx container, (installing requirements/edx/development.txt)

     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 60.5/60.5 KB 6.5 MB/s eta 0:00:00
Requirement already satisfied: libsass==0.10.0 in /openedx/venv/lib/python3.8/site-packages (from -r requirements/edx/development.txt (line 861)) (0.10.0)
Requirement already satisfied: loremipsum==1.0.5 in /openedx/venv/lib/python3.8/site-packages (from -r requirements/edx/development.txt (line 865)) (1.0.5)
Collecting lti-consumer-xblock==3.4.6
  Downloading lti_consumer_xblock-3.4.6-py3-none-any.whl (240 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 240.1/240.1 KB 18.7 MB/s eta 0:00:00
Requirement already satisfied: lxml==4.5.0 in /openedx/venv/lib/python3.8/site-packages (from -r requirements/edx/development.txt (line 871)) (4.5.0)
Collecting m2r==0.2.1
  Downloading m2r-0.2.1.tar.gz (16 kB)
  Preparing metadata (setup.py): started
  Preparing metadata (setup.py): finished with status 'error'
  error: subprocess-exited-with-error

  Γ— python setup.py egg_info did not run successfully.
  β”‚ exit code: 1
  ╰─> [8 lines of output]
      Traceback (most recent call last):
        File "<string>", line 2, in <module>
        File "<pip-setuptools-caller>", line 34, in <module>
        File "/tmp/pip-install-zum1lzwv/m2r_3383312d2e034baf9e436b5bfee97318/setup.py", line 14, in <module>
          from m2r import parse_from_file
        File "/tmp/pip-install-zum1lzwv/m2r_3383312d2e034baf9e436b5bfee97318/m2r.py", line 59, in <module>
          class RestBlockGrammar(mistune.BlockGrammar):
      AttributeError: module 'mistune' has no attribute 'BlockGrammar'
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed

Γ— Encountered error while generating package metadata.
╰─> See above for output.

note: This is an issue with the package mentioned above, not pip.
hint: See above for details.
WARNING: You are using pip version 22.0.4; however, version 22.2.2 is available.
You should consider upgrading via the '/openedx/venv/bin/python -m pip install --upgrade pip' command.
The command '/bin/sh -c pip install -r requirements/edx/development.txt' returned a non-zero code: 1

I’m not sure how to correct this, as it’s seemingly being caused by version conflicts in requirements/edx/development.txt which has not been modified from nutmeg.1 defaults and was building previously

additionally, after researching the error the proposed solution for this error is to revert versions for the pip packages m2r and mistune to the same versions listed in development.txt

even more confusing is there appears to be a commit directly addressing this issue in open-release/nutmeg.1
Commit to nutmeg.1 (not a fix, but at least a comment)

I’m at a loss on how to address this as it was working previously and seemingly nothing has changed in my code, and i’ve attempted reverting all changes, clearing build cache, building with the default repository with no success

If anyone has any information i can go on for this, it’d be GREATLY appreciated. or if i stumble across anyting i’ll be sure to update this thread

1 Like

(tried adding this to the post itself, but i cant edit for some reason)

Also forgot to note: I am using the pip install "tutor[full]=14.0.4" version of tutor

and the commands that are failing are:
tutor images build all
tutor images build openedx
tutor images build openedx --no-cache


Still no fix, :cry: but i was able to replicate the same error message in a separate environment.
(nothing special just upgraded the environment from Tutor v14.0.2 and attempted to rebuild using Tutor v14.0.4 and the same issue arose)

  • this separate instance was initially generated and functional by using a slightly older version of tutor, 14.0.2
  • it was not an upgraded copy of an older system (i.e. it was a fresh installation of tutor using 14.0.2 in this separate environment)

I’m not sure where to begin with a fix for this, as it seems to be coming from the dependencies of the platform itself. And given that i’m not getting much traffic on this post, i’m assuming not many people are experiencing this same issue, potentially ruling out an unexpected pip package update.

I’m attempting to roll back a version on tutor to see if the problem persists, but i don’t have high hopes. i’ll update this thread again if there’s any progress

also worth noting i’m seeing this open issue on the m2r pip package repo and i’m assuming this is playing a part in my problem.

Is noone else encountering this? it seems like it’d be more widespread than just me.

Finally, i can give myself some good news here.

The same error with the m2r and mistune packages were still present when building after downgrading Tutor, so i reverted back to Tutor v14.0.4

in an act of desperation i manually added the correct version of mistune to tutor’s private.txt and that appears to have allowed a build.

addition to private.txt:

# Add your additional requirements, such as xblocks, to this file. For
# requirements coming from private repositories, clone the repository to this
# folder and then add your requirement with the `-e` flag. Ex:
#   git clone git@myserver:myprivaterepo.git
#   echo "-e ./myprivaterepo/" >> private.txt

# ... other packages ...


This leads me to believe that something has changed either in the installed pip packages, or the openedx build process for tutor that’s causing it to grab the incorrect version of the mistune package. Which is odd since openedx specifies to grab mistune<2.0.0 in requirements/conditions.txt so either conditions.txt is being ignored during the build process, or something else beyond my knowledge is causing pip to grab the wrong version, leading to the error i was seeing

I imagine this is only useful as a band-aid until the bigger issue is addressed, but for now it’s working for me. (though i imagine there’s a better solution like a tutor plugin that could be used, but essentially doing the same thing)

Any thoughts on this @tutor-maintainers ?

@crivet Thanks for your detailed report here, and I’m glad you found a bandaid for the meantime.

@cmuniz , could you take a look when you have a chance? I recall you constrained mistune as part of the symmath refactoring because you hit a similar error. Do you have any ideas why @crivet might be hitting the same error now, even with your constraint in place?