在windows下使用pre-commit, pre-commit run --all-files
之后报错如下:
### error information
An unexpected error has occurred: CalledProcessError: command: ('c:\\programdata\\anaconda3\\python.exe', '-mvirtualenv', 'C:\\Users\\Administrator\\.cache\\pre-commit\\repokaf8xb0i\\py_env-python3.7', '-p', 'c:\\programdata\\anaconda3\\python.exe')
return code: 1
expected return code: 0
stdout:
FileNotFoundError: [Errno 2] No such file or directory: 'c:\\programdata\\anaconda3\\Lib\\venv\\scripts\\nt\\python.exe'
stderr: (none)
Traceback (most recent call last):
File "c:\programdata\anaconda3\lib\site-packages\pre_commit\error_handler.py", line 63, in error_handler
yield
File "c:\programdata\anaconda3\lib\site-packages\pre_commit\main.py", line 390, in main
return run(args.config, store, args)
File "c:\programdata\anaconda3\lib\site-packages\pre_commit\commands\run.py", line 388, in run
install_hook_envs(hooks, store)
File "c:\programdata\anaconda3\lib\site-packages\pre_commit\repository.py", line 206, in install_hook_envs
_hook_install(hook)
File "c:\programdata\anaconda3\lib\site-packages\pre_commit\repository.py", line 83, in _hook_install
hook.prefix, hook.language_version, hook.additional_dependencies,
File "c:\programdata\anaconda3\lib\site-packages\pre_commit\languages\python.py", line 213, in install_environment
cmd_output_b(*venv_cmd, cwd='/')
File "c:\programdata\anaconda3\lib\site-packages\pre_commit\util.py", line 157, in cmd_output_b
raise CalledProcessError(returncode, cmd, retcode, stdout_b, stderr_b)
pre_commit.util.CalledProcessError: command: ('c:\\programdata\\anaconda3\\python.exe', '-mvirtualenv', 'C:\\Users\\Administrator\\.cache\\pre-commit\\repokaf8xb0i\\py_env-python3.7', '-p', 'c:\\programdata\\anaconda3\\python.exe')
return code: 1
expected return code: 0
stdout:
FileNotFoundError: [Errno 2] No such file or directory: 'c:\\programdata\\anaconda3\\Lib\\venv\\scripts\\nt\\python.exe'
stderr: (none)
问题是python的virtualenv
库版本太高了,建议降级到20.0.33,解决方案来自(这里)[https://github.com/pre-commit/pre-commit/issues/1675]