Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ModuleNotFound : No module named "git"

Tags:

git

python-3.x

I was updating my git repo using the below command

python3 helper.py --update SomeName

But it is showing error like:

Traceback (most recent call last):
  File "helper.py", line 13, in <module>
          import git
ModuleNotFoundError: No module named 'git'

I have installed both Python 3 (3.8.5) and Python 2 (2.7.18).

like image 804
Silence Avatar asked Nov 17 '25 03:11

Silence


2 Answers

What worked in my case, on Windows, was

python3 -m pip install gitpython

Even after installing GitPython through pip3, the module was not being found, even if I included the appropriate paths. What worked is the command I mention.

like image 117
zois Avatar answered Nov 18 '25 17:11

zois


Following Installing GitPython, a simple pip install GitPython should be enough.

If not, check gitpython-developers/GitPython issue 1051:

Even though I don't know what is causing this I do know that GitPython 2.x is supposed to work with Python 2 and 3, whereas GitPython 3 only works with Python 3.

It's hard to understand what exactly happened here, but when running pip3 install GitPython I am also unable to successfully run import git.

My best guess is that pip installs things outside of the PYTHONPATH, which certainly is surprising

like image 40
VonC Avatar answered Nov 18 '25 17:11

VonC