添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接

failed to find interpreter when running black via pre-commit #1761

@levinotik

Description

I am suddenly having issues running black via pre-commit. Other pre-commit hooks work just fine. I have the following in my pre-commit config:

-   repo: https://github.com/psf/black
    rev: stable
    hooks:
    - id: black
      language_version: python3.7

I am using Python version 3.7.6 with pyenv. This setup has worked just fine for a long time.

Now, when committing my changes, I get the following error:

### version information
pre-commit version: 2.9.3
sys.version:
    3.9.1 (default, Jan  6 2021, 06:04:49) 
    [Clang 12.0.0 (clang-1200.0.32.28)]
sys.executable: /usr/local/Cellar/pre-commit/2.9.3/libexec/bin/python3
os.name: posix
sys.platform: darwin
### error information
An unexpected error has occurred: CalledProcessError: command: ('/usr/local/Cellar/pre-commit/2.9.3/libexec/bin/python3', '-mvirtualenv', '/Users/levinotik/.cache/pre-commit/repoc_gsawtf/py_env-python3.7', '-p', 'python3.7')
return code: 1
expected return code: 0
stdout:
    RuntimeError: failed to find interpreter for Builtin discover of python_spec='python3.7'
stderr: (none)
Traceback (most recent call last):
  File "/usr/local/Cellar/pre-commit/2.9.3/libexec/lib/python3.9/site-packages/pre_commit/error_handler.py", line 65, in error_handler
    yield
  File "/usr/local/Cellar/pre-commit/2.9.3/libexec/lib/python3.9/site-packages/pre_commit/main.py", line 347, in main
    return hook_impl(
  File "/usr/local/Cellar/pre-commit/2.9.3/libexec/lib/python3.9/site-packages/pre_commit/commands/hook_impl.py", line 217, in hook_impl
    return retv | run(config, store, ns)
  File "/usr/local/Cellar/pre-commit/2.9.3/libexec/lib/python3.9/site-packages/pre_commit/commands/run.py", line 402, in run
    install_hook_envs(hooks, store)
  File "/usr/local/Cellar/pre-commit/2.9.3/libexec/lib/python3.9/site-packages/pre_commit/repository.py", line 206, in install_hook_envs
    _hook_install(hook)
  File "/usr/local/Cellar/pre-commit/2.9.3/libexec/lib/python3.9/site-packages/pre_commit/repository.py", line 82, in _hook_install
    lang.install_environment(
  File "/usr/local/Cellar/pre-commit/2.9.3/libexec/lib/python3.9/site-packages/pre_commit/languages/python.py", line 202, in install_environment
    cmd_output_b(*venv_cmd, cwd='/')
  File "/usr/local/Cellar/pre-commit/2.9.3/libexec/lib/python3.9/site-packages/pre_commit/util.py", line 154, in cmd_output_b
    raise CalledProcessError(returncode, cmd, retcode, stdout_b, stderr_b)
pre_commit.util.CalledProcessError: command: ('/usr/local/Cellar/pre-commit/2.9.3/libexec/bin/python3', '-mvirtualenv', '/Users/levinotik/.cache/pre-commit/repoc_gsawtf/py_env-python3.7', '-p', 'python3.7')
return code: 1
expected return code: 0
stdout:
    RuntimeError: failed to find interpreter for Builtin discover of python_spec='python3.7'
stderr: (none)

I'm not sure how to resolve this or whether this is actually an upstream issue in black. Any ideas? Thanks