3

我遇到了安装预提交钩子的障碍。根据下面的错误,钩子安装在目录中找不到python exe C:\\Users\\dangler\\.cache\\pre-commit\\repoith5dg7x\\py_env-default\\Scripts\\python.EXE(该文件夹中不存在python.EXE......应该吗?)。在过去的几个小时里,我一直在尝试解决它,但无济于事。希望存在解决方案,也许我已经为它搜索了不正确的地方。

(fiddle-env) PS C:\Users\dangler\Documents\projects\fiddle> pre-commit clean
(fiddle-env) PS C:\Users\dangler\Documents\projects\fiddle> pre-commit install
(fiddle-env) PS C:\Users\dangler\Documents\projects\fiddle> git commit -am "README file with links"
[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: ('C:\\Users\\dangler\\.cache\\pre-commit\\repookmqanwy\\py_env-default\\Scripts\\python.EXE', '-mpip', 'install', '.')
return code: 3221225781
expected return code: 0
stdout: (none)
stderr: (none)
Check the log at C:\Users\dangler\.cache\pre-commit\pre-commit.log

.pre-commit-config.yml文件是这样的:

repos:
-   repo: https://github.com/pre-commit/pre-commit-hooks
    rev: v2.4.0
    hooks:
        -   id: double-quote-string-fixer
        -   id: check-added-large-files
        -   id: check-ast
        -   id: check-json
        -   id: check-yaml
        -   id: end-of-file-fixer
        -   id: no-commit-to-branch
        -   id: fix-encoding-pragma
        -   id: trailing-whitespace
-   repo: https://github.com/pre-commit/mirrors-autopep8
    rev: 'v1.4.4'  # Use the sha / tag you want to point at
    hooks:
        -   id: autopep8

4

1 回答 1

3

我可以通过使用以下命令降级虚拟环境来解决此问题:

pip install virtualenv==20.0.33

然后安装预提交挂钩。更多信息:

https://github.com/ContinuumIO/anaconda-issues/issues/12094#issuecomment-708557750

于 2020-12-08T05:50:37.180 回答