无法在python中导入git

Bha*_*yap 2 python windows git github

我正面临着这些问题.你能帮我一下吗?为什么我看到这个错误?我是否必须在requirements.txt文件中添加任何内容?

>>> import git
Traceback (most recent call last):
File "<pyshell#7>", line 1, in <module>
 import git
File "git\__init__.py", line 29, in <module>
_init_externals()
File "git\__init__.py", line 23, in _init_externals
raise ImportError("'gitdb' could not be found in your PYTHONPATH")
ImportError: 'gitdb' could not be found in your PYTHONPATH

>>> from git import Repo
Traceback (most recent call last):
File "<pyshell#8>", line 1, in <module>
from git import Repo
File "git\__init__.py", line 29, in <module>
_init_externals()
File "git\__init__.py", line 23, in _init_externals
raise ImportError("'gitdb' could not be found in your PYTHONPATH")
ImportError: 'gitdb' could not be found in your PYTHONPATH
Run Code Online (Sandbox Code Playgroud)

Jos*_*eia 11

我已经gitdbsmmap安装,所以我不得不重新安装它们。

您可以通过在终端中运行以下命令来重新安装它们:

pip3 install --upgrade --force-reinstall gitdb; pip3 install --upgrade --force-reinstall smmap
Run Code Online (Sandbox Code Playgroud)


Rom*_*man 5

我也得到了消息ImportError: 'gitdb' could not be found in your PYTHONPATH(当试图使用GitPython时).
但我已经安装了gitdb!
由于这个提示我发现gitdb默默失败,因为它缺少smmap.
所以我安装了它,它工作.


ozg*_*gur 3

您需要安装gitdb包。

$ sudo easy_install gitdb
Run Code Online (Sandbox Code Playgroud)