Pre-Commit schlägt mit ModuleNotFoundError fehl: Kein Modul mit dem Namen „yaml“

Post a reply

Smilies
:) :( :oops: :chelo: :roll: :wink: :muza: :sorry: :angel: :read: *x) :clever:
View more smilies

BBCode is ON
[img] is ON
[flash] is OFF
[url] is ON
Smilies are ON

Topic review
   

Expand view Topic review: Pre-Commit schlägt mit ModuleNotFoundError fehl: Kein Modul mit dem Namen „yaml“

by Guest » 18 Jan 2025, 22:22

Ich verwende Pre-Commit. In einem der Hooks verwende ich ein Python-Skript, das die Yaml-Bibliothek importiert.
Wenn ich jedoch versuche, etwas zu committen, erhalte ich bei diesem Hook die folgende Fehlermeldung:

Code: Select all

ModuleNotFoundError: No module named 'yaml'
Ich verstehe nicht, wo das Problem liegt, da pyyaml ordnungsgemäß in Python gefunden wird

Code: Select all

$ python3
Python 3.12.3 (main, Nov  6 2024, 18:32:19) [GCC 13.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import yaml
>>>
Hier ist meine .pre-commit-config.yml:

Code: Select all

repos:
# python hooks
- repo: local
hooks:
- id: yaml-arrays-sort
name: YAML Arrays Sort
description: Sort arrays in YAML files
entry: python scripts/yaml-arrays-sort.py
pass_filenames: false
language: python

Top