Wrong python version used by pre-commit

See original GitHub issue

Hi,

I’m facing this issue where my default Python on my system is 3.6.9, but pre-commit uses 3.6.0 in running the hooks.

➜   python --version
Python 3.6.9
➜  python3.6
Python 3.6.9 (default, Jun 12 2020, 10:30:48)
[GCC 4.2.1 Compatible Apple LLVM 11.0.0 (clang-1100.0.33.17)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> exit()

In my config, I pinned default_language_version to 3.6, and I expected pre-commit to use the latest release version that I have, ie. 3.6.9

default_language_version:
    python: python3.6
repos:
  - repo: https://github.com/asottile/pyupgrade
    rev: v2.1.0
    hooks:
      - id: pyupgrade
        args: [--py36-plus]

However, pre-commit used 3.6.0 instead, and threw the error below:

➜  pre-commit run --all-files
[INFO] Installing environment for https://github.com/asottile/pyupgrade.
[INFO] Once installed this environment will be reused.
[INFO] This may take a few minutes...
An unexpected error has occurred: CalledProcessError: command: ('/Users/blow/.cache/pre-commit/repo7_4ikr9y/py_env-python3.6/bin/python', '-mpip', 'install', '.')
return code: 1
expected return code: 0
stdout:
    Processing /Users/blow/.cache/pre-commit/repo7_4ikr9y

stderr:
    ERROR: Package 'pyupgrade' requires a different Python: 3.6.0 not in '>=3.6.1'

Check the log at /Users/blow/.cache/pre-commit/pre-commit.log

Pinning python3.6.9 for default_language_version in the config solves this problem, but I want to be able to not pin release versions and just pin python3.6.

Am I doing something wrong in my setup? Appreciate the help.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
beverlybiwenlowcommented, Jun 16, 2020

I resolved this by removing 3.6.0 from my machine. Thanks for your help and will close this now

0reactions
asottilecommented, Jun 15, 2020

@beverlybiwenlow any updates on this? could you also cd ~ && python3.6 --version

Read more comments on GitHub >

github_iconTop Results From Across the Web

pre-commit run The path python3.6 (from - Stack Overflow
The configuration for that repository sets language_version: python3.6 which is why it is attempting to use python3.6.
Read more >
pre-commit
Add a file called .pre-commit-config.yaml to the root of your project. The pre-commit config file describes what repositories and hooks are installed.
Read more >
pre-commit-hooks - PyPI
Simply check whether files parse as valid python. check-builtin-literals. Require literal syntax when initializing empty or zero Python builtin types. Allows ...
Read more >
Pycharm does not use virtualenv pep8 for git-hooks : PY-12988
If you have a similar config for your projects (Python version and not using ... If you add more hooks using .pre-commit-config.yaml or...
Read more >
Version control integration - Black 22.12.0 documentation
... is recommended to specify the latest version of Python # supported by your project here, or alternatively use # pre-commit's default_language_version, ...
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