pythonpre-commitpre-commit.comasdf

importlib.metadata error on pre-commit tool


I have installed pre-commit 3.0.1 via asdf. When I try to run pre-commit -v throwing the following error

Traceback (most recent call last):
  File "/Users/san/.cache/pre-commit-zipapp/6Bkef3U7os33XPapd4VZ7HEfyUexbeBTjOn51afz0r8/python", line 47, in <module>
    raise SystemExit(main())
  File "/Users/san/.cache/pre-commit-zipapp/6Bkef3U7os33XPapd4VZ7HEfyUexbeBTjOn51afz0r8/python", line 34, in main
    runpy.run_module(args.m, run_name='__main__', alter_sys=True)
  File "/Users/san/.pyenv/versions/3.7.9/lib/python3.7/runpy.py", line 205, in run_module
    return _run_module_code(code, init_globals, run_name, mod_spec)
  File "/Users/san/.pyenv/versions/3.7.9/lib/python3.7/runpy.py", line 96, in _run_module_code
    mod_name, mod_spec, pkg_name, script_name)
  File "/Users/san/.pyenv/versions/3.7.9/lib/python3.7/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/Users/san/.cache/pre-commit-zipapp/6Bkef3U7os33XPapd4VZ7HEfyUexbeBTjOn51afz0r8/wheels/pre_commit-3.0.1-py2.py3-none-any.whl/pre_commit/__main__.py", line 3, in <module>
    
  File "/Users/san/.cache/pre-commit-zipapp/6Bkef3U7os33XPapd4VZ7HEfyUexbeBTjOn51afz0r8/wheels/pre_commit-3.0.1-py2.py3-none-any.whl/pre_commit/main.py", line 9, in <module>
  File "/Users/san/.cache/pre-commit-zipapp/6Bkef3U7os33XPapd4VZ7HEfyUexbeBTjOn51afz0r8/wheels/pre_commit-3.0.1-py2.py3-none-any.whl/pre_commit/constants.py", line 3, in <module>
ModuleNotFoundError: No module named 'importlib.metadata'

Python version: 3.7.9

asdf version: v0.11.1


Solution

  • Upgrading the python to version 3.8.7 solved the issue, since for the pre-commit minimum required Python version is 3.8.