adrienverge/yamllint

No module named 'yaml' on v1.35.1

Closed this issue · 3 comments

I just bumped to the latest patch and am now getting errors. It works fine in v1.35.0.

I see this old issue, but am unsure what the fix was: #583

Traceback (most recent call last):
  File "/home/nick/.cache/pre-commit/reponknzeleg/py_env-python3.11/bin/yamllint", line 5, in <module>
    from yamllint.cli import run
  File "/home/nick/.cache/pre-commit/reponknzeleg/py_env-python3.11/lib/python3.11/site-packages/yamllint/cli.py", line 22, in <module>
    from yamllint import APP_DESCRIPTION, APP_NAME, APP_VERSION, linter
  File "/home/nick/.cache/pre-commit/reponknzeleg/py_env-python3.11/lib/python3.11/site-packages/yamllint/linter.py", line 19, in <module>
    import yaml
ModuleNotFoundError: No module named 'yaml'
Traceback (most recent call last):
  File "/home/nick/.cache/pre-commit/reponknzeleg/py_env-python3.11/bin/yamllint", line 5, in <module>
    from yamllint.cli import run
  File "/home/nick/.cache/pre-commit/reponknzeleg/py_env-python3.11/lib/python3.11/site-packages/yamllint/cli.py", line 22, in <module>
    from yamllint import APP_DESCRIPTION, APP_NAME, APP_VERSION, linter
  File "/home/nick/.cache/pre-commit/reponknzeleg/py_env-python3.11/lib/python3.11/site-packages/yamllint/linter.py", line 19, in <module>
    import yaml
ModuleNotFoundError: No module named 'yaml'

I am using yamllint via pre-commit with the following configuration:

repos:
  - repo: https://github.com/adrienverge/yamllint
    rev: v1.35.1
    hooks:
      - id: yamllint

It works for me with pre-commit version 3.8.0

This isn't a yamllint issue. pre-commit's community support channels may net you better results, but I can give you some suggestions:

  1. Uninstall and reinstall the pre-commit environment pre-commit uninstall && pre-commit install (that may actually only touch the hook not the cache)
  2. Delete the pre-commit cache rm -rf ~/.cache/pre-commit/ and retry

Appreciate the suggestion @andrewimeson, I'll give that a try.

I just tried, and it worked after rm -rf ~/.cache/pre-commit/.

Again, thanks for the help.