Unable to import git in python

I am facing these issues. Can you help me with the same ?
Why am I seeing this error ? Do I have to add anything in the requirements.txt file ?

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

  • Developing in eclipse without using any git eclipse plugin?
  • Git commit -a opens GNU nano 2.2.6 How should I change it to open Vim instead?
  • Git Log History
  • Git merge: is it possible to avoid auto-merge for non fast-forwarded files?
  • git submodule add fatal: Not a Git Repository
  • git: aborting pull because of Gemfile.lock file which would be overwritten, even though it is in the .gitignore file
  • Deploying changes to an app hosted on Heroku without using Git
  • Download Git repo without all the .git stuff?
  • git rebase after fixing conflict
  • Can't cd to directory which has spaces in the name
  • Clone a git repository all the way back to a specific commit, but not everything
  • How do I tell fugitive my path to Git on Windows?
  • 3 Solutions collect form web for “Unable to import git in python”

    You need to install gitdb package.

    $ sudo easy_install gitdb
    

    I also got the message ImportError: 'gitdb' could not be found in your PYTHONPATH (when trying to use GitPython).
    BUT I had gitdb already installed!
    Thanks to this hint I figured out that gitdb silently failed because it was missing smmap.
    So I installed this and it worked.

    I had the same problem. However, gitdb and smmap were already installed by pip. As I used brew to install python and its dependencies on my mac, when I checked brew doctor command, it said that my /usr/local/sbin directory is not in my PATH. So I added it to my PATH (though it didn’t have anything to do with the python) and everything worked out eventually.

    Git Baby is a git and github fan, let's start git clone.