我正在使用 Pycharm 并从 Github 克隆了一个存储库。当尝试设置我的预提交挂钩时,我在终端中安装了预提交,但是当尝试获取版本时,它说模块未找到但安装成功。有人有什么建议吗?
Users-MacBook-Pro:group_three_software user$ pip3 install pre-commit
Requirement already satisfied: pre-commit in /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages (3.3.3)
Requirement already satisfied: cfgv>=2.0.0 in /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages (from pre-commit) (3.3.1)
Requirement already satisfied: identify>=1.0.0 in /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages (from pre-commit) (2.5.26)
Requirement already satisfied: nodeenv>=0.11.1 in /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages (from pre-commit) (1.8.0)
Requirement already satisfied: pyyaml>=5.1 in /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages (from pre-commit) (6.0.1)
Requirement already satisfied: virtualenv>=20.10.0 in /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages (from pre-commit) (20.24.2)
Requirement already satisfied: setuptools in /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages (from nodeenv>=0.11.1->pre-commit) (63.2.0)
Requirement already satisfied: distlib<1,>=0.3.7 in /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages (from virtualenv>=20.10.0->pre-commit) (0.3.7)
Requirement already satisfied: filelock<4,>=3.12.2 in /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages (from virtualenv>=20.10.0->pre-commit) (3.12.2)
Requirement already satisfied: platformdirs<4,>=3.9.1 in /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages (from virtualenv>=20.10.0->pre-commit) (3.10.0)
Users-MacBook-Pro:group_three_software user$ python3 -m pre-commit --version
/usr/local/bin/python3: No module named pre-commit
尝试了 python3 -m pre-commit --version 和 $ pre-commit --version & 期望看到预提交的版本,然后添加预提交配置和挂钩脚本
模块名称为
pre_commit
,可执行文件为 pre-commit
,因此您需要 python -m pre_commit
或 pre-commit
免责声明:我写了预提交