Skip to content

Installing precommit hooks fails due to non-existent python binΒ #2299

Closed

Description

@russkel

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)

Activity

  1. asottile commented on Mar 22, 2022

    @asottile
    Member

    are you perhaps on debian unstable? python + virtualenv is known to be (completely) broken there for python3.10

    this should work:

    virtualenv venv
    venv/bin/python --version
    

    if it does not I'd recommend reporting to your distribution packager

  2. russkel commented on Mar 22, 2022

    @russkel
    Author

    are you perhaps on debian unstable? python + virtualenv is known to be (completely) broken there for python3.10

    It's on Ubuntu 22.04 so yes, some kind of unstable.

    Okay, didn't realise it was supposed to be running from an venv at this point. Annoying stuff.

    Thanks.

  3. asottile commented on Mar 22, 2022

    @asottile
    Member

    if you want to follow the long bpo thread here's where to start: https://bugs.python.org/issue45413

    I implemented a fix for deadsnakes for this but debian hasn't chosen their approach yet

  4. asottile commented on Apr 13, 2022

    @asottile
    Member

    fwiw I've made a temporary ppa repackaging python3.10 for jammy using the same patch as python3.10 for other deadsnakes distributions -- https://launchpad.net/~deadsnakes/+archive/ubuntu/python3.10-jammy

  5. russkel commented on Apr 13, 2022

    @russkel
    Author

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

  6. epigramx commented on Sep 22, 2022

    @epigramx

    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?

  7. asottile commented on Sep 22, 2022

    @asottile
    Member

    please email the debian maintainers, I've tried but they aren't convinced this is actually worth fixing

  8. epigramx commented on Sep 22, 2022

    @epigramx

    It makes pre-commit unusable for the largest distributions of Linux. Did someone link them this issue?
    Is there a workaround with environmental variables etc. without having someone build python?

  9. asottile commented on Sep 22, 2022

    @asottile
    Member

    (1) yes (2) yes see the linked issues

  10. epigramx commented on Sep 23, 2022

    @epigramx

    @asottile I don't get it, because I applied the patch from here at /usr/lib/python3.10/sysconfig.py, and I see no change while it was working with your ppa.

  11. asottile commented on Sep 23, 2022

    @asottile
    Member

    you will need to purge virtualenv's cache afterwards as it does not know to invalidate in that case

  12. asottile commented on Sep 23, 2022

    @asottile
    Member

    yeah you won't have to delete pre-commit's cache -- it has self-healing stuff for this already

  13. epigramx commented on Sep 23, 2022

    @epigramx

    hm alright, it needed a purge of ~/.local/share/virtualenv/ as well and not just a purge of a local .env in question, thanks.

  14. deleted a comment from matteius on Oct 16, 2022
  15. locked as off topic and limited conversation to collaborators on Oct 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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