Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error: No module named 'git' #1051

Open
joseoliverosgit opened this issue Sep 1, 2020 · 1 comment
Open

Error: No module named 'git' #1051

joseoliverosgit opened this issue Sep 1, 2020 · 1 comment

Comments

@joseoliverosgit
Copy link

@joseoliverosgit joseoliverosgit commented Sep 1, 2020

Trying to use gitpython on my Mac (Catalina 10.15.5) but no success yet. I hope you guys could help me:

  • Python 2.7 pre-installed on the machine, I have installed Python 3.8
  • When installing GitPython (no clean installation as I have already install/uninstall several times) I get following:

"DEPRECATION: Python 2.7 reached the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 is no longer maintained. pip 21.0 will drop support for Python 2.7 in January 2021. More details about Python 2 support in pip can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support
Collecting gitpython
Using cached GitPython-2.1.15-py2.py3-none-any.whl (452 kB)
Requirement already satisfied: gitdb2<3,>=2 in /Users/joseluisoliveros/Library/Python/2.7/lib/python/site-packages (from gitpython) (2.0.6)
Requirement already satisfied: smmap2>=2.0.0 in /Users/joseluisoliveros/Library/Python/2.7/lib/python/site-packages (from gitdb2<3,>=2->gitpython) (3.0.1)
Requirement already satisfied: smmap>=3.0.1 in /Users/joseluisoliveros/Library/Python/2.7/lib/python/site-packages (from smmap2>=2.0.0->gitdb2<3,>=2->gitpython) (3.0.4)
Installing collected packages: gitpython
Successfully installed gitpython-2.1.15"

  • When I try and run a Python with "import git" I get following:

Error: No module named 'git'

  • When running "python -version" I get following:

Python 3.8.5

@Byron
Copy link
Member

@Byron Byron commented Sep 2, 2020

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, but then again, it's Python… .

>>> import sys
>>> sys.path
['', '/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.8/lib/python38.zip', '/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8', '/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/lib-dynload', '/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/site-packages']
>

But the package is installed here:

gitoxide git:(main) pip3 uninstall gitpython
Found existing installation: GitPython 3.1.7
Uninstalling GitPython-3.1.7:
  Would remove:
    /usr/local/lib/python3.8/site-packages/GitPython-3.1.7.dist-info/*
    /usr/local/lib/python3.8/site-packages/git/*
Proceed (y/n)?

I think adding the respective site-packages directory to the PYTHONPATH should do the trick.
Please let me know if this fixes the problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.