Skip to content

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

Description

@mell0

Requirments file includes gitdb2 and, but "compat.py" file is importing "gitdb" instead and throwing missing "gitdb" module error when this library is fresh installed in a new enviroment with missing "gitdb" dependency library. Please fix the problem.

Activity

  1. davidwneary commented on Feb 17, 2020

    @davidwneary

    Experiencing the same here.

    from gitdb.utils.compat import (
     ModuleNotFoundError: No module named 'gitdb.utils.compat'
    

    We're using the 3.0.5 release. Looks like the latest release to gitdb (3.0.2) has caused the issue - if I add gitdb2==3.0.1 to my requirements.txt, it's fixed.

  2. Harmon758 commented on Feb 17, 2020

    @Harmon758
    Member

    @davidwneary Ah, that issue is due to GitDB v3.0.2 removing gitdb.utils.compat.
    I'll push a fix momentarily.
    That import was removed with GitPython v3.0.6 (b5dd2f0, a10ceef, 5d22d57) so the latest versions shouldn't have that issue.

    @mell0 gitdb2 is the same gitdb library renamed on PyPI due to loss of access to the original PyPI account. See gitpython-developers/gitdb#45, gitpython-developers/gitdb#47, and pypi/support#204. The import remains gitdb.

  3. Harmon758 commented on Feb 17, 2020

    @Harmon758
    Member

    @davidwneary Actually, that import was removed with v3.0.6. This should be resolved in the latest versions.

  4. Harmon758 commented on Feb 17, 2020

    @Harmon758
    Member

    @mell0 I'm unable to reproduce this in a new environment with the latest versions of both libraries, i.e. gitpython v3.0.8 and gitdb2 v3.0.2. If your issue is different, can you provide the details of your environment, e.g. gitpython, gitdb2, and python versions, and the full traceback?

  5. mell0 commented on Feb 17, 2020

    @mell0
    Author

    Hi,

    Problem is when trying to install an older version for GitPython which I had in my test requirements file, to be specific v3.0.4. I understood that this was fixed in versions above v3.0.6. It's just that v3.0.4 should have used in its requirements working gitdb2 version with compat included, because now I have a lot of deployment fails of my apps and I'm sure it's not only me. In my opinion requirements should contain more specific version of the dependencies not just >=, because thus way people using older version and relying on it are suffering and in general at the moment older versions <=v3.0.6 are not working.

  6. mell0 commented on Feb 17, 2020

    @mell0
    Author

    To reproduce, just create new virtual env, try to install GitPython==3.0.4, and try to import it.

  7. Harmon758 commented on Feb 17, 2020

    @Harmon758
    Member

    I agree that the versioning is less than ideal here. In fact, GitPython shouldn't have been using GitDB compatibility shims in the first place, causing the removal to be a breaking change, as they should have been internal rather than exposed.

    I've gone ahead and restricted the gitdb2 version to < 4 now with e81fd54 to mitigate future issues like this, and it should be part of the next release.

    However, there's not much that can be done at this point for older versions that rely on gitdb2 < 3.0.2. Even if the GitDB removal was reverted, since it wasn't restricted to < or <= any certain version for GitPython, any breaking change in the future would still break older GitPython versions.
    But since the only GitPython version requirement for gitdb2 was >= 2 for older versions, you can simply specify gitdb2 < 3.0.2 in your own dependencies if you want to continue using an older version of GitPython.

    In fact, there was an issue with the formatting of the version specifier that wasn't fixed until GitPython v3.0.6, so you should be able to specify and install any gitdb2 version (although I can't guarantee that it'll work with < 2). It's just that, by default, the latest version will be installed.

  8. fmigneault commented on Feb 18, 2020

    @fmigneault

    @Harmon758
    You could do a post release (https://www.python.org/dev/peps/pep-0440/#post-releases).
    An hotfix for such a thing would avoid many unexpected problems by devs that tagged this version in order to have stable code, but suddenly still get an error.

    I would also argue that using the patch number instead of (at least) minor for such big refactoring isn't really a best practice to avoid situations like this in the future.

  9. 28 remaining items

  10. unpinned this issue on Apr 11, 2020
  11. mmaithani commented on Dec 4, 2020

    @mmaithani

    Experiencing the same here.

    from gitdb.utils.compat import (
     ModuleNotFoundError: No module named 'gitdb.utils.compat'
    

    We're using the 3.0.5 release. Looks like the latest release to gitdb (3.0.2) has caused the issue - if I add gitdb2==3.0.1 to my requirements.txt, it's fixed.

    yeah 3.0.1 worked for me too, Thanks !

  12. added a commit that references this issue on Jun 9, 2022
  13. added a commit that references this issue on Aug 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions