带有 git 预提交钩子的 CalledProcessError

Dan*_*ger 6 git pre-commit pre-commit-hook conda pre-commit.com

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

\n
(fiddle-env) PS C:\\Users\\dangler\\Documents\\projects\\fiddle> pre-commit clean\n(fiddle-env) PS C:\\Users\\dangler\\Documents\\projects\\fiddle> pre-commit install\n(fiddle-env) PS C:\\Users\\dangler\\Documents\\projects\\fiddle> git commit -am "README file with links"\n[INFO] Installing environment for https://github.com/pre-commit/pre-commit-hooks.\n[INFO] Once installed this environment will be reused.\n[INFO] This may take a few minutes...\nAn unexpected error has occurred: CalledProcessError: command: ('C:\\\\Users\\\\dangler\\\\.cache\\\\pre-commit\\\\repookmqanwy\\\\py_env-default\\\\Scripts\\\\python.EXE', '-mpip', 'install', '.')\nreturn code: 3221225781\nexpected return code: 0\nstdout: (none)\nstderr: (none)\nCheck the log at C:\\Users\\dangler\\.cache\\pre-commit\\pre-commit.log\n
Run Code Online (Sandbox Code Playgroud)\n

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

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

Dan*_*ger 8

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

pip install virtualenv==20.0.33
Run Code Online (Sandbox Code Playgroud)

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

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