question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Installing precommit hooks fails due to non-existent python bin

See original GitHub issue

Looks like a call to python is hard coded when it shouldn’t be.

↳ pre-commit run --all-files
[INFO] Initializing environment for https://github.com/pre-commit/pre-commit-hooks.
[INFO] Initializing environment for https://github.com/asottile/pyupgrade.
[INFO] Initializing environment for https://github.com/psf/black.
[INFO] Initializing environment for https://github.com/pycqa/flake8.
[INFO] Initializing environment for https://github.com/codespell-project/codespell.
[INFO] Installing environment for https://github.com/pre-commit/pre-commit-hooks.
[INFO] Once installed this environment will be reused.
[INFO] This may take a few minutes...
An unexpected error has occurred: CalledProcessError: command: ('python', '-mpip', 'install', '.')
return code: 1
expected return code: 0
stdout:
    Executable `python` not found
stderr: (none)
Check the log at /home/russ/.cache/pre-commit/pre-commit.log

Running on Ubuntu jammy with python 3.10. /usr/bin/python does not exist.

version information

pre-commit version: 2.17.0
git --version: git version 2.34.1
sys.version:
    3.10.3 (main, Mar 16 2022, 17:19:40) [GCC 11.2.0]
sys.executable: /usr/bin/python3
os.name: posix
sys.platform: linux

error information

An unexpected error has occurred: CalledProcessError: command: ('python', '-mpip', 'install', '.')
return code: 1
expected return code: 0
stdout:
    Executable `python` not found
stderr: (none)
Traceback (most recent call last):
  File "/home/russ/.local/lib/python3.10/site-packages/pre_commit/error_handler.py", line 70, in error_handler
    yield
  File "/home/russ/.local/lib/python3.10/site-packages/pre_commit/main.py", line 396, in main
    return run(args.config, store, args)
  File "/home/russ/.local/lib/python3.10/site-packages/pre_commit/commands/run.py", line 416, in run
    install_hook_envs(to_install, store)
  File "/home/russ/.local/lib/python3.10/site-packages/pre_commit/repository.py", line 224, in install_hook_envs
    _hook_install(hook)
  File "/home/russ/.local/lib/python3.10/site-packages/pre_commit/repository.py", line 82, in _hook_install
    lang.install_environment(
  File "/home/russ/.local/lib/python3.10/site-packages/pre_commit/languages/python.py", line 205, in install_environment
    helpers.run_setup_cmd(prefix, install_cmd)
  File "/home/russ/.local/lib/python3.10/site-packages/pre_commit/languages/helpers.py", line 52, in run_setup_cmd
    cmd_output_b(*cmd, cwd=prefix.prefix_dir, **kwargs)
  File "/home/russ/.local/lib/python3.10/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: ('python', '-mpip', 'install', '.')
return code: 1
expected return code: 0
stdout:
    Executable `python` not found
stderr: (none)

Issue Analytics

  • State:closed
  • Created a year ago
  • Reactions:4
  • Comments:13 (7 by maintainers)

github_iconTop GitHub Comments

2reactions
epigramxcommented, Sep 22, 2022

This problem returned at large for the common user, because 22.04.1 LTS updated its python to 3.10.6. Is there a new workaround?

1reaction
russkelcommented, Apr 13, 2022

Thanks a lot for that @asottile. I will install. I wish ubuntu would get it sorted already.

Read more comments on GitHub >

github_iconTop Results From Across the Web

git - pre-commit/hook: No such file or directory - Stack Overflow
Go to .git/hooks directory and remove pre-commit file, as its trying to reference to node_modules/pre-commit/hook .
Read more >
Pre-commit Hook - Prettier
You can use Prettier with a pre-commit tool. This can re-format your files that are marked as “staged” via `git add` before you...
Read more >
Essential developer tools for improving your Python code
After installing the pre-commit and pre-push hooks, the tools will be triggered upon every commit and push to the git repository. You can ......
Read more >
Install pre-commit Hook for ESP-IDF Project - Espressif Systems
pre-commit may fail when initializing an environment for a particular hook when the path of pre-commit 's cache contains non-ASCII characters. The solution...
Read more >
Git server hooks - GitLab Docs
Prefix each message with GL-HOOK-ERR: with no characters appearing before the prefix. For example: #!/bin/sh echo "GL-HOOK-ERR: My custom error message ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found