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

Can't run tests ("Requiring namespace 'Gtk' version '3.0', but '4.0' is already loaded") #4688

Closed
geajack opened this issue Jan 1, 2023 · 4 comments

Comments

@geajack
Copy link

geajack commented Jan 1, 2023

When I run make test on the current version of master, I get a bunch of crazy errors:

======================================================================
ERROR: lutris.util.test_config (nose2.loader.ModuleImportFailure)
----------------------------------------------------------------------
ImportError: Failed to import test module: lutris.util.test_config
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/gi/importer.py", line 142, in load_module
    introspection_module = get_introspection_module(namespace)
  File "/usr/lib/python3/dist-packages/gi/module.py", line 257, in get_introspection_module
    module = IntrospectionModule(namespace, version)
  File "/usr/lib/python3/dist-packages/gi/module.py", line 109, in __init__
    repository.require(namespace, version)
gi.RepositoryError: Requiring namespace 'Gdk' version '3.0', but '4.0' is already loaded

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.10/dist-packages/nose2/plugins/loader/discovery.py", line 204, in _find_tests_in_file
    module = util.module_from_name(module_name)
  File "/usr/local/lib/python3.10/dist-packages/nose2/util.py", line 76, in module_from_name
    __import__(name)
  File "/home/jack/Code/External/Lutris/Codebase/lutris/util/test_config.py", line 7, in <module>
    from lutris import startup
  File "/home/jack/Code/External/Lutris/Codebase/lutris/startup.py", line 9, in <module>
    from lutris.game import Game
  File "/home/jack/Code/External/Lutris/Codebase/lutris/game.py", line 13, in <module>
    from gi.repository import GLib, GObject, Gtk
  File "/usr/lib/python3/dist-packages/gi/importer.py", line 144, in load_module
    raise ImportError(e)
ImportError: Requiring namespace 'Gdk' version '3.0', but '4.0' is already loaded

...and again and again, more or less the same error repeated many times.

A similar problem was mentioned here.

As a sidenote, I found it very difficult to install nose2 ("very difficult" meaning I had to do more than just run pip), would it be possible to drop it in favor of pytest or something? It seems like an unnecessary barrier to potential new contributors.

@danieljohnson2
Copy link
Contributor

That is very strange. But "make test" works for me.

Nose2 installs for me via "pip3 install nose2"- what more did you need to do?

I recall that on Pop!_OS, I had to uninstall 'flake8' via APT and then install it via pip3 to get the right version of it. I was having trouble with it, not the tests, though. Maybe something like that is at issue?

In any case the unit tests are pretty limited; 'make flake8' and 'make pytest' and the really useful tools, I find.

@geajack
Copy link
Author

geajack commented Jan 1, 2023

Nose2 installs for me via "pip3 install nose2"- what more did you need to do?

It was kind of messy so I don't quite remember - I think I needed to sudo install it (which I usually don't), but since it failed when I initially tried to pip install it I think I got sidetracked and ended up doing a bunch of weird stuff I found on google like installing it via apt. It's possible I'm exaggerating the problem.

@danieljohnson2
Copy link
Contributor

Well, on my distro the APT version of flake8 was old, so I suspect that sort of thing may be happening to you. Maybe apt remove all this stuff and pip3 install it (without sudo- install it for your account)

Things get messy when there are different versions of packages installed in different places; try to get it consistant.

@strycore
Copy link
Member

strycore commented Jan 9, 2024

fixed

@strycore strycore closed this as completed Jan 9, 2024
@lutris lutris locked as resolved and limited conversation to collaborators Feb 27, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants