failed to find interpreter when running black via pre-commit
See original GitHub issueI 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
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:8 (4 by maintainers)
Top Results From Across the Web
failed to find interpreter for Builtin discover of python_spec ...
While trying to use pre-commit hooks, I am experiencing some difficulties, including the latest Lava-nc release by Intel in .tar.gz format pip ...
Read more >pre-commit
We run our hooks on every commit to automatically point out issues in code such as missing semicolons, trailing whitespace, and debug statements....
Read more >Pycharm does not use virtualenv pep8 for git-hooks : PY-12988
I have pre-commit hook when i commit using Pycharm - it not using PATH from virtualenv (default project interpreter) and use system pep8...
Read more >Contributing to the code base — pandas 1.5.2 documentation
Using hypothesis #. Hypothesis is a library for property-based testing. Instead of explicitly parametrizing a test, you can describe all valid inputs and...
Read more >Python HOW: Using Poetry, Make, and pre-commit-hooks to ...
If the prerequisite interpreter path doesn't exist, you will get an error when running the venv target. Makefile > line 12 is where...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Gotcha. Makes sense. Thanks so much for helping even though this wasn’t a
pre-commit
issue.Thanks a lot, really appreciate it. Interesting, I had
language_version: python3.7
in myblack
settings inpre-commit-config.yaml
. Changing that tolanguage_version: python3
does seem to resolve the issue!Here’s what I get for the things you asked about:
and