adrienverge / yamllint

A linter for YAML files.
GNU General Public License v3.0
2.83k stars 269 forks source link

No module named 'yaml' on MacOS #583

Closed hhemied closed 1 year ago

hhemied commented 1 year ago

I'm getting the following errors when I run any related yamllint command.

➜ yamllint --help
Traceback (most recent call last):
  File "/usr/local/bin/yamllint", line 5, in <module>
    from yamllint.cli import run
  File "/usr/local/lib/python3.9/site-packages/yamllint/cli.py", line 27, in <module>
    from yamllint import linter
  File "/usr/local/lib/python3.9/site-packages/yamllint/linter.py", line 19, in <module>
    import yaml
ModuleNotFoundError: No module named 'yaml'

I used brew to install yamllint and ensured that pyyaml and libyaml are also installed.

andrewimeson commented 1 year ago
  1. Is it a fresh installation from Homebrew and it broke immediately, or did it work for a while and upgrades may have broken it?
  2. How did you install pyyaml and libyaml? Is it possible you installed them into a different Python environment?

Troubleshooting commands:

brew doctor
which python3
python3 -m pip freeze | grep -i -e yamllint -e pyyaml

To force a reinstall brew uninstall yamllint && brew install yamllint

hhemied commented 1 year ago

Thank @andrewimeson for the hint. brew doctor showed unlinked formula Now fixed and working again.