Skip to content

ModuleNotFoundError: No module named 'pkg_resources' when installing environment #2122

@andreoliwa

Description

@andreoliwa

Hi.

I'm getting the error below both on Python 3.10.0 and 3.9.7, only on this mirrors-prettier repo.

[INFO] Installing environment for https://github.com/pre-commit/mirrors-prettier.
[INFO] Once installed this environment will be reused.
[INFO] This may take a few minutes...
An unexpected error has occurred: CalledProcessError: command: ('/Users/aa/.pyenv/versions/3.10.0/bin/python3', '/Users/aa/.cache/pre-commit-zipapp/veR-6hXwmzX2ScBOxSDU3KDEapmTGSUiy_rUDxSkW24/python', '-mnodeenv', '--prebuilt', '--clean-src', '/Users/aa/.cache/pre-commit/repoj2j9vjbi/node_env-system', '-n', 'system')
return code: 1
expected return code: 0
stdout: (none)
stderr:
    Traceback (most recent call last):
      File "/Users/aa/.cache/pre-commit-zipapp/veR-6hXwmzX2ScBOxSDU3KDEapmTGSUiy_rUDxSkW24/python", line 48, in <module>
        exit(main())
      File "/Users/aa/.cache/pre-commit-zipapp/veR-6hXwmzX2ScBOxSDU3KDEapmTGSUiy_rUDxSkW24/python", line 32, in main
        runpy.run_module(args.m, run_name='__main__', alter_sys=True)
      File "/Users/aa/.pyenv/versions/3.10.0/lib/python3.10/runpy.py", line 209, in run_module
        return _run_module_code(code, init_globals, run_name, mod_spec)
      File "/Users/aa/.pyenv/versions/3.10.0/lib/python3.10/runpy.py", line 96, in _run_module_code
        _run_code(code, mod_globals, init_globals,
      File "/Users/aa/.pyenv/versions/3.10.0/lib/python3.10/runpy.py", line 86, in _run_code
        exec(code, run_globals)
      File "/Users/aa/.cache/pre-commit-zipapp/veR-6hXwmzX2ScBOxSDU3KDEapmTGSUiy_rUDxSkW24/wheels/nodeenv-1.6.0-py2.py3-none-any.whl/nodeenv.py", line 48, in <module>
    ModuleNotFoundError: No module named 'pkg_resources'

Check the log at /Users/aa/.cache/pre-commit/pre-commit.log
make: *** [.cache/make/pre-commit] Error 3
  1. Other pre-commit repos work fine.
  2. None of them are NodeJS repos as far as I know.
  3. It's happening on a freshly installed computer; it works on my old one.
  4. I wonder if it has something to do with my NodeJS installation, but I'm not sure and I don't know how to debug it.
  5. Let me know if I have to post more information about my system.

Below is what I tried so far, to no success.
I'd appreciate any lead, hint or help.

Thanks!


I tried reinstalling setuptools with both python executables:

Details
❯ /Users/aa/.pyenv/versions/3.10.0/bin/python3 -m pip install -U pip setuptools
Requirement already satisfied: pip in /Users/aa/.pyenv/versions/3.10.0/lib/python3.10/site-packages (21.3.1)
Requirement already satisfied: setuptools in /Users/aa/.pyenv/versions/3.10.0/lib/python3.10/site-packages (58.5.3)
❯ /Users/aa/.cache/pre-commit-zipapp/veR-6hXwmzX2ScBOxSDU3KDEapmTGSUiy_rUDxSkW24/python -m ensurepip
Looking in links: /var/folders/t_/w0p3tjc95tjd0vld929q66rh0000gn/T/tmpcc0nkqh6
Requirement already satisfied: setuptools in /Users/aa/.pyenv/versions/3.10.0/lib/python3.10/site-packages (58.5.3)
Requirement already satisfied: pip in /Users/aa/.pyenv/versions/3.10.0/lib/python3.10/site-packages (21.3.1)
❯ /Users/aa/.cache/pre-commit-zipapp/veR-6hXwmzX2ScBOxSDU3KDEapmTGSUiy_rUDxSkW24/python -m pip install -U pip setuptools
Traceback (most recent call last):
  File "/Users/aa/.cache/pre-commit-zipapp/veR-6hXwmzX2ScBOxSDU3KDEapmTGSUiy_rUDxSkW24/python", line 48, in <module>
    exit(main())
  File "/Users/aa/.cache/pre-commit-zipapp/veR-6hXwmzX2ScBOxSDU3KDEapmTGSUiy_rUDxSkW24/python", line 32, in main
    runpy.run_module(args.m, run_name='__main__', alter_sys=True)
  File "/Users/aa/.pyenv/versions/3.10.0/lib/python3.10/runpy.py", line 205, in run_module
    mod_name, mod_spec, code = _get_module_details(mod_name)
  File "/Users/aa/.pyenv/versions/3.10.0/lib/python3.10/runpy.py", line 140, in _get_module_details
    raise error("No module named %s" % mod_name)
ImportError: No module named pip

Here are the contents of /Users/aa/.cache/pre-commit/pre-commit.log:

/Users/aa/.cache/pre-commit/pre-commit.log

version information

pre-commit version: 2.15.0
sys.version:
    3.10.0 (default, Oct 31 2021, 00:48:30) [Clang 12.0.5 (clang-1205.0.22.11)]
sys.executable: /Users/aa/.cache/pre-commit-zipapp/veR-6hXwmzX2ScBOxSDU3KDEapmTGSUiy_rUDxSkW24/python
os.name: posix
sys.platform: darwin

error information

An unexpected error has occurred: CalledProcessError: command: ('/Users/aa/.pyenv/versions/3.10.0/bin/python3', '/Users/aa/.cache/pre-commit-zipapp/veR-6hXwmzX2ScBOxSDU3KDEapmTGSUiy_rUDxSkW24/python', '-mnodeenv', '--prebuilt', '--clean-src', '/Users/aa/.cache/pre-commit/repoj2j9vjbi/node_env-system', '-n', 'system')
return code: 1
expected return code: 0
stdout: (none)
stderr:
    Traceback (most recent call last):
      File "/Users/aa/.cache/pre-commit-zipapp/veR-6hXwmzX2ScBOxSDU3KDEapmTGSUiy_rUDxSkW24/python", line 48, in <module>
        exit(main())
      File "/Users/aa/.cache/pre-commit-zipapp/veR-6hXwmzX2ScBOxSDU3KDEapmTGSUiy_rUDxSkW24/python", line 32, in main
        runpy.run_module(args.m, run_name='__main__', alter_sys=True)
      File "/Users/aa/.pyenv/versions/3.10.0/lib/python3.10/runpy.py", line 209, in run_module
        return _run_module_code(code, init_globals, run_name, mod_spec)
      File "/Users/aa/.pyenv/versions/3.10.0/lib/python3.10/runpy.py", line 96, in _run_module_code
        _run_code(code, mod_globals, init_globals,
      File "/Users/aa/.pyenv/versions/3.10.0/lib/python3.10/runpy.py", line 86, in _run_code
        exec(code, run_globals)
      File "/Users/aa/.cache/pre-commit-zipapp/veR-6hXwmzX2ScBOxSDU3KDEapmTGSUiy_rUDxSkW24/wheels/nodeenv-1.6.0-py2.py3-none-any.whl/nodeenv.py", line 48, in <module>
    ModuleNotFoundError: No module named 'pkg_resources'
    
Traceback (most recent call last):
  File "/Users/aa/.cache/pre-commit-zipapp/veR-6hXwmzX2ScBOxSDU3KDEapmTGSUiy_rUDxSkW24/wheels/pre_commit-2.15.0-py2.py3-none-any.whl/pre_commit/error_handler.py", line 65, in error_handler
    yield
  File "/Users/aa/.cache/pre-commit-zipapp/veR-6hXwmzX2ScBOxSDU3KDEapmTGSUiy_rUDxSkW24/wheels/pre_commit-2.15.0-py2.py3-none-any.whl/pre_commit/main.py", line 396, in main
    return run(args.config, store, args)
  File "/Users/aa/.cache/pre-commit-zipapp/veR-6hXwmzX2ScBOxSDU3KDEapmTGSUiy_rUDxSkW24/wheels/pre_commit-2.15.0-py2.py3-none-any.whl/pre_commit/commands/run.py", line 417, in run
    install_hook_envs(to_install, store)
  File "/Users/aa/.cache/pre-commit-zipapp/veR-6hXwmzX2ScBOxSDU3KDEapmTGSUiy_rUDxSkW24/wheels/pre_commit-2.15.0-py2.py3-none-any.whl/pre_commit/repository.py", line 224, in install_hook_envs
    _hook_install(hook)
  File "/Users/aa/.cache/pre-commit-zipapp/veR-6hXwmzX2ScBOxSDU3KDEapmTGSUiy_rUDxSkW24/wheels/pre_commit-2.15.0-py2.py3-none-any.whl/pre_commit/repository.py", line 82, in _hook_install
    lang.install_environment(
  File "/Users/aa/.cache/pre-commit-zipapp/veR-6hXwmzX2ScBOxSDU3KDEapmTGSUiy_rUDxSkW24/wheels/pre_commit-2.15.0-py2.py3-none-any.whl/pre_commit/languages/node.py", line 97, in install_environment
    cmd_output_b(*cmd)
  File "/Users/aa/.cache/pre-commit-zipapp/veR-6hXwmzX2ScBOxSDU3KDEapmTGSUiy_rUDxSkW24/wheels/pre_commit-2.15.0-py2.py3-none-any.whl/pre_commit/util.py", line 154, in cmd_output_b
    raise CalledProcessError(returncode, cmd, retcode, stdout_b, stderr_b)
pre_commit.util.CalledProcessError: command: ('/Users/aa/.pyenv/versions/3.10.0/bin/python3', '/Users/aa/.cache/pre-commit-zipapp/veR-6hXwmzX2ScBOxSDU3KDEapmTGSUiy_rUDxSkW24/python', '-mnodeenv', '--prebuilt', '--clean-src', '/Users/aa/.cache/pre-commit/repoj2j9vjbi/node_env-system', '-n', 'system')
return code: 1
expected return code: 0
stdout: (none)
stderr:
    Traceback (most recent call last):
      File "/Users/aa/.cache/pre-commit-zipapp/veR-6hXwmzX2ScBOxSDU3KDEapmTGSUiy_rUDxSkW24/python", line 48, in <module>
        exit(main())
      File "/Users/aa/.cache/pre-commit-zipapp/veR-6hXwmzX2ScBOxSDU3KDEapmTGSUiy_rUDxSkW24/python", line 32, in main
        runpy.run_module(args.m, run_name='__main__', alter_sys=True)
      File "/Users/aa/.pyenv/versions/3.10.0/lib/python3.10/runpy.py", line 209, in run_module
        return _run_module_code(code, init_globals, run_name, mod_spec)
      File "/Users/aa/.pyenv/versions/3.10.0/lib/python3.10/runpy.py", line 96, in _run_module_code
        _run_code(code, mod_globals, init_globals,
      File "/Users/aa/.pyenv/versions/3.10.0/lib/python3.10/runpy.py", line 86, in _run_code
        exec(code, run_globals)
      File "/Users/aa/.cache/pre-commit-zipapp/veR-6hXwmzX2ScBOxSDU3KDEapmTGSUiy_rUDxSkW24/wheels/nodeenv-1.6.0-py2.py3-none-any.whl/nodeenv.py", line 48, in <module>
    ModuleNotFoundError: No module named 'pkg_resources'

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions