ModuleNotFoundError: No module named 'gramps'

Upgraded python from 3.8 to 3.11 on Debian 11. Tried running Gramps only to get “ModuleNotFoundError: No module named ‘gramps’”. Removed Gramps 5.1.3 and downloaded Gramps 5.1.5 Debian package. Installed that and got the same error when trying to run Gramps. Did a pip install gramps to see if that would help, and it didn’t. Any ideas how to fix this?

Thanks.

Maybe raise a bug report and provide a bit more information like what output you get when running Gramps from the command line?

Upgraded python from 3.8 to 3.11 on Debian 11.

Does downgrading Python make it work?

This means that the file/directory structure of Gramps is not the one expected by the application.

  • Either you have created a shortcut on your desktop to launch quickly it by copying the Gramps.py script. Then, at launch time, the current directory is the desktop, not the Gramps directory, and Python can’t import the various modules because they aren’t in the current directory.
  • Or, you have tampered in some way with the names of the directories in Gramps tree. Perhaps, you have installed manually in some “non-standard” directory.

Usually, packages also install “launchers” in the Applications menu (or equivalent, you didn’t tell which desktop is yours: Gnome, KDE Plasma, LxQt, LXDE, …) with accurate parameters. As far as I can tell on my Fedora box, Gramps is put into the Python library, so that all implicit dependencies are satisfied.

I think the problem is the python call.

The first line of/usr/bin/gramps is #!/usr/bin/python3 -O

Is there /usr/bin/python3?
If no, replace python3 with python

yeap, that was it. I changed it to call python3.9 and it worked (with the exception image metadata but I will look into that). It still, however, wort work with python3.11.

Thanks.

Thanks. I’ll make a bug report.

I think this is a debian problem, not a gramps problem.
What are the different pythons you have?
ls -l /usr/bin/python*

I think it would be best to link in/usr/bin
If we use python3, it’s for all OS. If we change that, we’ll have problems with others like ubuntu, fedora…

Perhaps using update-alternatives --list python3

I look at my debian and I have:
$ ls -l /usr/bin/python*
lrwxrwxrwx 1 root root 10 août 18 12:39 /usr/bin/python3 → python3.9
-rwxr-xr-x 1 root root 5921160 nov. 14 17:10 /usr/bin/python3.9

So this is the solution. We don’t need to modify gramps.

I have python 3.9 and python 3.11. It all worked fine under python 3.9. The problem started after I upgraded to 3.11. But if I set gramps to use 3.9 then the problem is fixed.

OK, two questions:

  1. Why did you install Python 3.11?
  2. Can run “gramps --version” in terminal, and show what you see in the PYTHONPATH?

I have a custom built Gramps 5.1 running on LMDE 5, which is based on Debian 11, and on that the current Python version is 3.9.2, and the PYTHONPAST shown by Gramps is:

    /usr/local/lib/python3.9/dist-packages/gramps
    /usr/local/bin
    /usr/lib/python39.zip
    /usr/lib/python3.9
    /usr/lib/python3.9/lib-dynload
    /usr/local/lib/python3.9/dist-packages
    /usr/lib/python3/dist-packages
    /usr/lib/python3.9/dist-packages

And when I look inside the folder listed first, I see Gramps’ source files installed.

This suggests that the Gramps version that we distribute relies on this version, and when you try to run Gramps with Python 3.11. it will look for modules inside /usr/local/lib/python3.11 which has most probably no gramps folder in it.

1 Like

I am under Fedora 37 which installed Python 3.11 (no other Python 3.x). Gramps works smoothly. So this is not a matter of library dependency but probably of the location of dist-packages. Gramps is stored in the 3.9 directory and not in the 3.11, therefore invisible from Python 3.11. If Python 3.11 was installed with the package manager and made the “current” Python interpreter, it might be worth to reinstall Gramps so that it lands in the correct directory (or create a link to the existing directory).

I understand what you’re saying, but you need to realize that the we have a lot of different packages, so your experience with Fedora can be quite different from what we have with Debian, Mint, or ubuntu.

And in this particular case, where the user has Python 3.9 and 3.11, it may very well be that the installer, working with a .deb file downloaded from our site, sees that 3.9 is good enough to run Gramps, and doesn’t check whether there is any other version, and installs Gramps into the 3.9 application folder. And that’s quite understandable, because most users have one version for Python 2, and another one for Python 3.

By installing Python 3.11, and not staying with the 3.9, the user has created a context that was probably not known to the developer who created the Debian packages for different versions, and related distributions, nor for the person that created the Debian package that we have on our site, which works fine on LMDE 5 and Mint 21. And it’s that context that counts.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.