Skip to content

Failed to install with pip installation failure for m2r: AttributeError: module 'mistune' has no attribute 'BlockGrammar' #1105

@nguerrera

Description

@nguerrera

I'm trying to debug an issue where Azure/cadl-azure started failing the PR validation step that runs autorest. I think this is part of the problem, but I must admit that this is very foreign to me.

Repro

$ npm install -g autorest
$ autorest --use=@autorest/python@5.11.2

Output

SourceMapConsumer.initialize is a no-op when running in node.js
AutoRest code generation utility [cli version: 3.5.1; node: v16.13.0]
(C) 2018 Microsoft Corporation.
https://aka.ms/autorest
installing core... [========================================] 100% | 2/2
SourceMapConsumer.initialize is a no-op when running in node.js
info    |    Loading AutoRest core      'C:\Users\nicholg\.autorest\@autorestcore@3.7.2\nodemodules\@autorest\core\dist' (3.7.2)
info    |    Installing AutoRest extension '@autorest/python' (5.11.2 -> 5.11.2)
installing... [========================================] 100% | 918/918
error   |   Error: Package '@autorest/python' - '5.11.2' failed to install:
  Failed to install package 'https://registry.npmjs.org/@autorest/python/-/python-5.11.2.tgz' -- Error: Process Failed.

Installation logs:

  | warning: package.json: No license field
  | info: No lockfile found.
  | info:  Step: Resolving packages
  | warning: https://registry.npmjs.org/ > @azure-tools/extension > npm > libcipm@4.0.8: This module is no longer used. Please see @npmcli/arborist if you would like to build and reify package trees programmatically.
  | warning: https://registry.npmjs.org/ > @azure-tools/extension > npm > request@2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142
  | warning: https://registry.npmjs.org/ > @azure-tools/extension > npm > node-gyp > request@2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142
  | warning: https://registry.npmjs.org/ > @azure-tools/extension > npm > uuid@3.4.0: Please upgrade  to version 7 or higher.  Older versions may use Math.random() in certain circumstances, which is known to be problematic.  See https://v8.dev/blog/math-random for details.
  | warning: https://registry.npmjs.org/ > @azure-tools/extension > npm > request > uuid@3.4.0: Please upgrade  to version 7 or higher.  Older versions may use Math.random() in certain circumstances, which is known to be problematic.  See https://v8.dev/blog/math-random for details.
  | warning: https://registry.npmjs.org/ > @azure-tools/extension > npm > request > har-validator@5.1.5: this library is no longer supported
  | info:  Step: Fetching packages
  | info:  Step: Linking dependencies
  | info:  Step: Building fresh packages
  | error: C:\Users\nicholg\.autorest\@autorestpython@5.11.2\nodemodules\@autorest\python: Command failed.
  |        Exit code: 2147483651
  |        Command: node run-python3.js install.py
  |        Arguments:
  |        Directory: C:\Users\nicholg\.autorest\@autorestpython@5.11.2\nodemodules\@autorest\python
  |        Output:
  |        AssignProcessToJobObject: (87) The parameter is incorrect.
  |        Executing: C:\Users\nicholg\.autorest\@autorestpython@5.11.2\nodemodules\@autorest\python\venv\Scripts\python.exe -m pip install -U pip
  |        Requirement already satisfied: pip in c:\users\nicholg\.autorest\@autorestpython@5.11.2\nodemodules\@autorest\python\venv\lib\site-packages (21.2.3)
  |        Collecting pip
  |          Using cached pip-21.3.1-py3-none-any.whl (1.7 MB)
  |        Installing collected packages: pip
  |          Attempting uninstall: pip
  |            Found existing installation: pip 21.2.3
  |            Uninstalling pip-21.2.3:
  |              Successfully uninstalled pip-21.2.3
  |        Successfully installed pip-21.3.1
  |        Executing: C:\Users\nicholg\.autorest\@autorestpython@5.11.2\node_modules\@autorest\python\venv\Scripts\python.exe -m pip install -e C:\Users\nicholg\.autorest\@autorest_python@5.11.2\nodemodules\@autorest\python
  |        Obtaining file:///C:/Users/nicholg/.autorest/%40autorestpython%405.11.2/nodemodules/%40autorest/python
  |          Preparing metadata (setup.py): started
  |          Preparing metadata (setup.py): finished with status 'done'
  |        Collecting json-rpc
  |          Using cached json_rpc-1.13.0-py2.py3-none-any.whl (41 kB)
  |        Collecting Jinja2>=2.11
  |          Using cached Jinja2-3.0.3-py3-none-any.whl (133 kB)
  |        Collecting pyyaml
  |          Using cached PyYAML-6.0-cp310-cp310-win_amd64.whl (151 kB)
  |        Collecting m2r
  |          Using cached m2r-0.2.1.tar.gz (16 kB)
  |          Preparing metadata (setup.py): started
  |          Preparing metadata (setup.py): finished with status 'done'
  |        Collecting black
  |          Using cached black-21.12b0-py3-none-any.whl (156 kB)
  |        Collecting MarkupSafe>=2.0
  |          Using cached MarkupSafe-2.0.1-cp310-cp310-win_amd64.whl (15 kB)
  |        Collecting typing-extensions>=3.10.0.0
  |          Using cached typing_extensions-4.0.1-py3-none-any.whl (22 kB)
  |        Collecting pathspec<1,>=0.9.0
  |          Using cached pathspec-0.9.0-py2.py3-none-any.whl (31 kB)
  |        Collecting tomli<2.0.0,>=0.2.6
  |          Using cached tomli-1.2.2-py3-none-any.whl (12 kB)
  |        Collecting platformdirs>=2
  |          Using cached platformdirs-2.4.0-py3-none-any.whl (14 kB)
  |        Collecting click>=7.1.2
  |          Using cached click-8.0.3-py3-none-any.whl (97 kB)
  |        Collecting mypy-extensions>=0.4.3
  |          Using cached mypy_extensions-0.4.3-py2.py3-none-any.whl (4.5 kB)
  |        Collecting mistune
  |          Using cached mistune-2.0.0-py2.py3-none-any.whl (24 kB)
  |        Collecting docutils
  |          Using cached docutils-0.18.1-py2.py3-none-any.whl (570 kB)
  |        Collecting colorama
  |          Using cached colorama-0.4.4-py2.py3-none-any.whl (16 kB)
  |        Using legacy 'setup.py install' for m2r, since package 'wheel' is not installed.
  |        Installing collected packages: colorama, typing-extensions, tomli, platformdirs, pathspec, mypy-extensions, mistune, MarkupSafe, docutils, click, pyyaml, m2r, json-rpc, Jinja2, black, autorest
  |            Running setup.py install for m2r: started
  |            Running setup.py install for m2r: finished with status 'error'
  |            ERROR: Command errored out with exit status 1:
  |             command: 'C:\Users\nicholg\.autorest\@autorestpython@5.11.2\node_modules\@autorest\python\venv\Scripts\python.exe' -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\nicholg\\AppData\\Local\\Temp\\pip-install-1g_rw0h7\\m2r_d676854841de452b9858e6a28f74f95d\\setup.py'"'"'; __file__='"'"'C:\\Users\\nicholg\\AppData\\Local\\Temp\\pip-install-1g_rw0h7\\m2r_d676854841de452b9858e6a28f74f95d\\setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record 'C:\Users\nicholg\AppData\Local\Temp\pip-record-hyxbuqoy\install-record.txt' --single-version-externally-managed --compile --install-headers 'C:\Users\nicholg\.autorest\@autorest_python@5.11.2\nodemodules\@autorest\python\venv\include\site\python3.10\m2r'
  |                 cwd: C:\Users\nicholg\AppData\Local\Temp\pip-install-1grw0h7\m2rd676854841de452b9858e6a28f74f95d\
  |            Complete output (7 lines):
  |            Traceback (most recent call last):
  |              File "<string>", line 1, in <module>
  |              File "C:\Users\nicholg\AppData\Local\Temp\pip-install-1grw0h7\m2rd676854841de452b9858e6a28f74f95d\setup.py", line 14, in <module>
  |                from m2r import parsefromfile
  |              File "C:\Users\nicholg\AppData\Local\Temp\pip-install-1grw0h7\m2rd676854841de452b9858e6a28f74f95d\m2r.py", line 59, in <module>
  |                class RestBlockGrammar(mistune.BlockGrammar):
  |            AttributeError: module 'mistune' has no attribute 'BlockGrammar'
  |            ----------------------------------------
  |        ERROR: Command errored out with exit status 1: 'C:\Users\nicholg\.autorest\@autorestpython@5.11.2\node_modules\@autorest\python\venv\Scripts\python.exe' -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\nicholg\\AppData\\Local\\Temp\\pip-install-1g_rw0h7\\m2r_d676854841de452b9858e6a28f74f95d\\setup.py'"'"'; __file__='"'"'C:\\Users\\nicholg\\AppData\\Local\\Temp\\pip-install-1g_rw0h7\\m2r_d676854841de452b9858e6a28f74f95d\\setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record 'C:\Users\nicholg\AppData\Local\Temp\pip-record-hyxbuqoy\install-record.txt' --single-version-externally-managed --compile --install-headers 'C:\Users\nicholg\.autorest\@autorest_python@5.11.2\nodemodules\@autorest\python\venv\include\site\python3.10\m2r' Check the logs for full command output.
  |        Command '['C:\\Users\\nicholg\\.autorest\\@autorestpython@5.11.2\\node_modules\\@autorest\\python\\venv\\Scripts\\python.exe', '-m', 'pip', 'install', '-e', 'C:\\Users\\nicholg\\.autorest\\@autorest_python@5.11.2\\nodemodules\\@autorest\\python']' returned non-zero exit status 1.
  | info: Visit https://yarnpkg.com/en/docs/cli/add for documentation about this command.

fatal   | Failed to install extension '@autorest/python' (5.11.2)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions