ModuleNotFoundError: No module named 'gitdb.utils.compat'

Hi,

I am getting this error ModuleNotFoundError: No module named 'gitdb.utils.compat' after bench update.

Below the full text:

Enumerating objects: 90, done.
remote: Counting objects: 100% (79/79), done.
remote: Compressing objects: 100% (13/13), done.
remote: Total 18 (delta 12), reused 6 (delta 5), pack-reused 0
Unpacking objects: 100% (18/18), done.
From https://github.com/frappe/bench
   189d0c7..1f5c7ec  master     -> origin/master
Updating 189d0c7..1f5c7ec
Fast-forward
 .deepsource.toml                     |  16 +++++++++
 .travis.yml                          | 114 ++++++++++++++++++++++++++++++++++++++++++++++------------
 bench/app.py                         | 131 ++++++++++++++++++++++++++++++++++++-------------------------------
 bench/commands/update.py             |   3 --
 bench/tests/test_base.py             |  96 +++++++++++++++++++++++++++++++++++++++++++++++++
 bench/tests/test_init.py             | 241 +++++++++++++++++++++++++++++++--------------------------------------------------------------------------------------------
 bench/tests/test_setup_production.py |  92 ++++++++++++++++++++---------------------------
 bench/utils.py                       |   2 +-
 8 files changed, 375 insertions(+), 320 deletions(-)
 create mode 100644 .deepsource.toml
 create mode 100644 bench/tests/test_base.py
INFO:bench.utils:Bench Updated!
Traceback (most recent call last):
  File "/usr/local/bin/bench", line 11, in <module>
    load_entry_point('bench', 'console_scripts', 'bench')()
  File "/usr/local/lib/python3.6/dist-packages/pkg_resources/__init__.py", line 489, in load_entry_point
    return get_distribution(dist).load_entry_point(group, name)
  File "/usr/local/lib/python3.6/dist-packages/pkg_resources/__init__.py", line 2793, in load_entry_point
    return ep.load()
  File "/usr/local/lib/python3.6/dist-packages/pkg_resources/__init__.py", line 2411, in load
    return self.resolve()
  File "/usr/local/lib/python3.6/dist-packages/pkg_resources/__init__.py", line 2417, in resolve
    module = __import__(self.module_name, fromlist=['__name__'], level=0)
  File "/home/frappe/.bench/bench/cli.py", line 4, in <module>
    from bench.app import get_apps
  File "/home/frappe/.bench/bench/app.py", line 15, in <module>
    import git
  File "/usr/local/lib/python3.6/dist-packages/git/__init__.py", line 38, in <module>
    from git.exc import *                       # @NoMove @IgnorePep8
  File "/usr/local/lib/python3.6/dist-packages/git/exc.py", line 9, in <module>
    from git.compat import UnicodeMixin, safe_decode, string_types
  File "/usr/local/lib/python3.6/dist-packages/git/compat.py", line 16, in <module>
    from gitdb.utils.compat import (
ModuleNotFoundError: No module named 'gitdb.utils.compat'
1 Like

This ModuleNotFoundError: No module named 'gitdb.utils.compat' · Issue #983 · gitpython-developers/GitPython · GitHub

advises “simply upgrade to the latest version of either major version, i.e. 3.0.8 or 2.1.15”

Here’s how to do that:

frappe@ubuntu:~/frappe-bench$ ./env/bin/pip install --upgrade GitPython
Collecting GitPython
Downloading GitPython-3.1.0-py3-none-any.whl (450 kB)
|████████████████████████████████| 450 kB 650 kB/s
Collecting gitdb<5,>=4.0.1
Downloading gitdb-4.0.2-py3-none-any.whl (63 kB)
|████████████████████████████████| 63 kB 181 kB/s
Collecting smmap<4,>=3.0.1
Downloading smmap-3.0.1-py2.py3-none-any.whl (25 kB)
ERROR: frappe 12.2.1 has requirement GitPython==2.1.11, but you’ll have gitpython 3.1.0 which is incompatible.
Installing collected packages: smmap, gitdb, GitPython
Attempting uninstall: GitPython
Found existing installation: GitPython 2.1.11
Uninstalling GitPython-2.1.11:
Successfully uninstalled GitPython-2.1.11
Successfully installed GitPython-3.1.0 gitdb-4.0.2 smmap-3.0.1

1 Like
root@Ubuntu18:/home/netmanthan/frappe-bench# bench update --reset
Traceback (most recent call last):
  File "/usr/local/bin/bench", line 11, in <module>
    load_entry_point('bench', 'console_scripts', 'bench')()
  File "/usr/local/lib/python3.6/dist-packages/pkg_resources/__init__.py", line 489, in load_entry_point
    return get_distribution(dist).load_entry_point(group, name)
  File "/usr/local/lib/python3.6/dist-packages/pkg_resources/__init__.py", line 2793, in load_entry_point
    return ep.load()
  File "/usr/local/lib/python3.6/dist-packages/pkg_resources/__init__.py", line 2411, in load
    return self.resolve()
  File "/usr/local/lib/python3.6/dist-packages/pkg_resources/__init__.py", line 2417, in resolve
    module = __import__(self.module_name, fromlist=['__name__'], level=0)
  File "/home/netmanthan/.bench/bench/cli.py", line 4, in <module>
    from bench.app import get_apps
  File "/home/netmanthan/.bench/bench/app.py", line 15, in <module>
    import git
  File "/usr/local/lib/python3.6/dist-packages/git/__init__.py", line 38, in <module>
    from git.exc import *                       # @NoMove @IgnorePep8
  File "/usr/local/lib/python3.6/dist-packages/git/exc.py", line 9, in <module>
    from git.compat import UnicodeMixin, safe_decode, string_types
  File "/usr/local/lib/python3.6/dist-packages/git/compat.py", line 16, in <module>
    from gitdb.utils.compat import (
ModuleNotFoundError: No module named 'gitdb.utils.compat'

unable to update

same error

Traceback (most recent call last):
  File "/usr/local/lib/python3.6/dist-packages/pkg_resources/__init__.py", line 583, in _build_master
    ws.require(__requires__)
  File "/usr/local/lib/python3.6/dist-packages/pkg_resources/__init__.py", line 900, in require
    needed = self.resolve(parse_requirements(requirements))
  File "/usr/local/lib/python3.6/dist-packages/pkg_resources/__init__.py", line 791, in resolve
    raise VersionConflict(dist, req).with_context(dependent_req)
pkg_resources.ContextualVersionConflict: (GitPython 3.0.0 (/usr/local/lib/python3.6/dist-packages), Requirement.parse('GitPython==2.1.11'), {'bench'})

showing another issues if i follow this

I tried found another issues

Collecting GitPython==3.0.4
  Using cached GitPython-3.0.4-py3-none-any.whl (454 kB)
Requirement already satisfied: gitdb2>=2.0.0 in /usr/local/lib/python3.6/dist-packages (from GitPython==3.0.4) (4.0.2)
Requirement already satisfied: gitdb>=4.0.1 in /usr/local/lib/python3.6/dist-packages (from gitdb2>=2.0.0->GitPython==3.0.4) (4.0.2)
Requirement already satisfied: smmap<4,>=3.0.1 in /usr/local/lib/python3.6/dist-packages (from gitdb>=4.0.1->gitdb2>=2.0.0->GitPython==3.0.4) (3.0.1)
ERROR: bench 4.1.0 has requirement GitPython==2.1.11, but you'll have gitpython 3.0.4 which is incompatible.
Installing collected packages: GitPython
  Attempting uninstall: GitPython
    Found existing installation: GitPython 2.1.11
    Uninstalling GitPython-2.1.11:
      Successfully uninstalled GitPython-2.1.11
Successfully installed GitPython-3.0.4

after this also not able to update.

showing below messages

    raise DistributionNotFound(req, requirers)
pkg_resources.DistributionNotFound: The 'GitPython==2.1.11' distribution was not found and is required by bench

Ah yes my bad, the links below both suggest this:

pip install -U -e $(bench src)

https://discuss.frappe.io/t/bench-error-after-upgrade/58631/8

pip install --upgrade gitdb2==2.0.6 gitdb==0.6.4

I run above command to resolve the issues.

1 Like

use this below command to solve

pip install --upgrade gitdb2==2.0.6 gitdb==0.6.4

I did
pip install --upgrade GitPython==2.1.15
pip install --upgrade gitdb2==2.0.6 gitdb==0.6.4

and solved the issue.

thanks @clarkej and @netmanthan

2 Likes

Hello guys
i have been trying to update using bench update, but i get this error ImportError: No module named ‘gitdb.utils.compat’
any help would be appreciated
Thanks

I did bench update but now it shows:

Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 583, in _build_master
    ws.require(__requires__)
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 900, in require
    needed = self.resolve(parse_requirements(requirements))
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 791, in resolve
    raise VersionConflict(dist, req).with_context(dependent_req)
pkg_resources.ContextualVersionConflict: (GitPython 2.1.15 (/home/bench/.local/lib/python3.7/site-packages), Requirement.parse('GitPython==2.1.11'), {'bench'})

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/bench/.local/bin/bench", line 6, in <module>
    from pkg_resources import load_entry_point
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 3191, in <module>
    @_call_aside
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 3175, in _call_aside
    f(*args, **kwargs)
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 3204, in _initialize_master_working_set
    working_set = WorkingSet._build_master()
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 585, in _build_master
    return cls._build_from_requirements(__requires__)
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 598, in _build_from_requirements
    dists = ws.resolve(reqs, Environment())
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 786, in resolve
    raise DistributionNotFound(req, requirers)
pkg_resources.DistributionNotFound: The 'GitPython==2.1.11' distribution was not found and is required by bench

Every call on bench results in the same issue.

Does anyone know how to solve it?

what version do you have ?
if you don’t know write this command
bench version

there is threads about simller issue here maybe help

Seems like bench’s requirements are not updated.
Does pip install -U {path/to/bench-repo} help?

After running bench update, I got the same error when call bench.
Solved it by running python3 -m pip install GitPython==2.1.11

2 Likes

This command was also not working anymore.

I somehow managed by cleaning up my python installation.

1 Like

Maybe this is happening because the bench-repo has GitPython==2.1.15 as a requirement whereas frappe has GitPython==2.1.11 as a requirement

Nope. bench’s dependencies are installed at system level while frappe’s requirements are installed in a virtual environment. Updating your system’s dependencies to match with the requirements.txt in bench should work.

As I previously mentioned in this thread, pip install -U -e $(bench src) should fix the issue.

2 Likes

Got it. Thanks