Virtual manager error "ModuleNotFoundError: No module named 'gi'"

I had installed virtual manager on EndevourOS before and it work perfectly, but randomly it stop opening so when I open it by terminal it gives this error. I search about it but no solution works, I already upgrade the system and reinstall virt-manager, but it still doesn’t work

Try reinstalling python-pygobject

Do you have another version of python installed, by chance? What does which python3 return? Does running /usr/bin/python3 virt-manager work?

Actually, I recently installed python 3.12.11 along with python 3.13.5 because I was working with tensorflow.

This is the output of python3:

 yui-u  yui-ASUS-TUF  ~  python3
Python 3.12.11 (main, Jun 24 2025, 13:03:59) [GCC 15.1.1 20250425] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>

Apparently the main version of python my system is using is 3.12.11, Maybe that’s the problem? And if it is, What should I do to fix it?

OK, that’s the reason why you can’t run virt-manager anymore. The gi module is installed for python3.13, located here: /usr/lib/python3.13/site-packages/gi. You will need python3.13 to use it.

EDIT: Try running /usr/bin/python3.13 /usr/bin/virt-manager.

FYI, if you need to install another version of python, I would strongly suggest not installing it through yay or pacman, but using a virtual environment manager like uv or pyenv. Since your new default python does not match the one installed with the system, you’re bound to run into this issue again.

OK, first I tried the command and got this:

 yui-u  yui-ASUS-TUF  ~  /usr/bin/python3.13 virt-manager
/usr/bin/python3.13: can't open file '/home/yui-u/virt-manager': [Errno 2] No such file or directory

Then I thought of installing python 3.13 the same way I install python 3.12 to make it the main python in the system.
I didn’t install python 3.12 with pacman nor yay, I download the Python-3.12.11.tar.xz from python.org and execute sudo make install.
Right now I repeat the process but with python 3.13.5 and now when I execute python3 I get:

Python 3.13.5 (main, Jul  7 2025, 18:25:40) [GCC 15.1.1 20250425] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> 

That’s a step foward I guess. but virt-manager still doesn’t work and /usr/bin/python3.13 virt-manager still the same output…

Any idea?

BTW I don’t mind delete python 3.12 or the other 3.13 I have install if that means installing them the correct way and not my ‘If it works it works’ way

There’s no reason to install python 3.13.5 the way you did, it’s part of the base Arch/EOS installation. Where did sudo make install put its files? If in /usr, then you’ve really messed your system up; if in /usr/local, then just delete all of the files/directories.

In the future, if you want to install source tarballs, don’t use the default installation location. I made an edit on my original post; please try the command to run virt-manager again. With the overwriting of python3.13, I really don’t know what to expect.

Wow! It actually works. Thanks man, and sorry for taking your time with my… Reckless methods to say less. Now I just have to see how do I repair whatever I have done.

1 Like

No worries. I did the exact same thing when I was playing around with the Nix package manager. Installed its version of python, screwed up virt-manager.

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