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

Error "ModuleNotFoundError: No module named 'typing_extensions'" with ansible-lint-6.17.0 #3515

Closed
nvuillam opened this issue May 31, 2023 · 4 comments · Fixed by #3517
Closed

Comments

@nvuillam
Copy link

Install line in an Dockerfile (installed via pip in a venv), docker base image is python:3.11.3-alpine3.17

RUN PYTHONDONTWRITEBYTECODE=1 pip3 install --no-cache-dir --upgrade pip virtualenv     && mkdir -p "/venvs/ansible-lint" && cd "/venvs/ansible-lint" && virtualenv . && source bin/activate && PYTHONDONTWRITEBYTECODE=1 pip3 install --no-cache-dir ansible-lint && deactivate && cd ./../..      && find . | grep -E "(/__pycache__$|\.pyc$|\.pyo$)" | xargs rm -rf && rm -rf /root/.cache

....

#12 37.36 Successfully installed MarkupSafe-2.1.2 ansible-compat-4.1.1 ansible-core-2.15.0 ansible-lint-6.17.0 attrs-23.1.0 black-23.3.0 bracex-2.3.post1 cffi-1.15.1 click-8.1.3 cryptography-41.0.0 filelock-3.12.0 jinja2-3.1.2 jsonschema-4.17.3 markdown-it-py-2.2.0 mdurl-0.1.2 mypy-extensions-1.0.0 packaging-23.1 pathspec-0.11.1 platformdirs-3.5.1 pycparser-2.21 pygments-2.15.1 pyrsistent-0.19.3 pyyaml-6.0 resolvelib-1.0.1 rich-13.4.0 ruamel.yaml-0.17.31 ruamel.yaml.clib-0.2.7 subprocess-tee-0.4.1 wcmatch-8.4.1 yamllint-1.32.0

Then when calling ansible-lint (every type of call, even --version like in the following example), we have a crash ModuleNotFoundError: No module named 'typing_extensions'

Linter version command: ['/venvs/ansible-lint/bin/ansible-lint', '--version']
Linter version result: 1 Traceback (most recent call last):
  File "/venvs/ansible-lint/bin/ansible-lint", line 5, in <module>
    from ansiblelint.__main__ import _run_cli_entrypoint
  File "/venvs/ansible-lint/lib/python3.11/site-packages/ansiblelint/__main__.py", line 39, in <module>
    from ansiblelint import cli
  File "/venvs/ansible-lint/lib/python3.11/site-packages/ansiblelint/cli.py", line 29, in <module>
    from ansiblelint.yaml_utils import clean_json
  File "/venvs/ansible-lint/lib/python3.11/site-packages/ansiblelint/yaml_utils.py", line 31, in <module>
    from ansiblelint.utils import Task
  File "/venvs/ansible-lint/lib/python3.11/site-packages/ansiblelint/utils.py", line 56, in <module>
    from ansiblelint.app import get_app
  File "/venvs/ansible-lint/lib/python3.11/site-packages/ansiblelint/app.py", line 17, in <module>
    from ansiblelint.color import console, console_stderr, render_yaml
  File "/venvs/ansible-lint/lib/python3.11/site-packages/ansiblelint/color.py", line 7, in <module>
    import rich.markdown
  File "/venvs/ansible-lint/lib/python3.11/site-packages/rich/markdown.py", line 7, in <module>
    from typing_extensions import get_args
ModuleNotFoundError: No module named 'typing_extensions'

Error visible here -> https://github.com/oxsecurity/megalinter/actions/runs/5135029416/jobs/9239897146?pr=2708

Is there any workaround ?

Many thanks :)

@nvuillam nvuillam added bug new Triage required labels May 31, 2023
@ssbarnea
Copy link
Member

ssbarnea commented May 31, 2023

To me this looks like a bug to report to rich library itself, which apparently is doing an import from typing_extensions at runtime without declaring it as a runtime dependency.

Interestingly it seems to be Textualize/rich#2386

Which version of rich do you have? Try to update rick to latest and try again. We need to identify which version is causing it.

You should also install lock extra which is pinning the dependencies to the versions that passed our testing.

@nvuillam
Copy link
Author

The error is seen when installing ansible-lint, I'm probably not the only one to have it ^^

For the moment I downgrade ansible-lint in MegaLinter , but maybe you could downgrade rich version ? :)

@btravouillon
Copy link
Contributor

I hit this this morning a few minutes after the release of https://pypi.org/project/rich/13.4.0/. The workaround was to pin `rich<13.4.0'
Reported in Textualize/rich#2979 and fixed in rich 13.4.1.

@nvuillam
Copy link
Author

@ssbarnea we made the same PR at the same time 🤣

@ssbarnea ssbarnea removed the new Triage required label Sep 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants