Modulenotfound: No Module Named "Git"

Modulenotfound: No Module Named "Git"

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).

3

2 Answers

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

0

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Sophia Al-Mansoor
Author

Sophia Al-Mansoor

Sophia analyzes international trade, startup ecosystems, retail transformation, and supply chain logistics for modern digital publications.