![](/img/trans.png)
[英]pre-commit x VSCode: env: python3.9: No such file or directory
[英]env: python3.9: No such file or directory
我有一些 python 代码格式化程序作为 git pre-commit 钩子,我已经将我的 python 版本更改为
brew list | grep python
python@3.7
python@3.9
brew unlink python@3.7
brew unlink python@3.9
brew link python@3.7
python -V
Python 3.7.9
并且知道似乎有些东西坏了,在 git commit 上我得到env: python3.9: No such file or directory
,那么env
是什么? 以及如何编辑它以使用python@3.7
?
在.git/hooks/pre-commit
我有
#!/usr/bin/env python3.9
并运行pre-commit install
其修复为#!/usr/bin/env python3.7
尽管@mrgloom 的回答为我指明了正确的方向,但这还不足以解决我的情况。
在我从 Ubuntu 21.10 升级到 22.04 后,这个错误才发生在我身上。 显然,安装的 Python 版本不再是 Python 3.9。 所以我很快检查了我现在有 3.10。
简单地用 Python3.10 编辑.git/hooks/pre-commit
是不够的。
对我有用的是重新安装预提交: https ://pre-commit.com/#install
因此,您可以运行pip install pre-commit
或brew install pre-commit
。
对我来说,我删除了旧的虚拟环境并重新创建它并工作:
$ deactivate
$ python3 -m venv env
$ source env/bin/activate
希望这能解决您的问题,谢谢!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.