Fix ImportError: No module named ‘gi’ in Mint 18

by Daniel Pham
Published: Updated:

Today, I will guide you to handle the error ImportError: No module named ‘gi’ that I have encountered. What is this error and how to solve it. Please read this article to see how I handled this problem.

The story happened

Today, a nice day and I want to upgrade my laptop operating system from Mint Cinnamon 17.3 to the latest version is 18.3.

Everything looks good and I can see my operating system upgraded to 18.3.

But things will never be the same. I use ibus-unikey to type in Vietnamese. After the upgrade I can not open IBus Preferences, I open the menu window and type in the search box Ibus Preferences, click on it and nothing happens.

Fix ImportError: No module named 'gi' in Mint 18
Open Ibus Preferences in Mint 18.

You can read this article to see how to install Ibus-unikey on Linux Mint.

After opening the Menu Editor (I will guide you in another article), I know that the Ibus Preferences menu calls the ibus-setup command. I open the Terminal window and type ibus-setup to see what’s going on.

Errors appear: ImportError: No module named ‘gi’

After i typed ibus-setup, the following error occurred. At this moment, I still do not understand what it is.

Traceback (most recent call last):
  File "/usr/share/ibus/setup/", line 31, in <module>
    from gi.repository import GLib
ImportError: No module named 'gi'

After a while searching, the instructions mainly say that my system is missing python-gi, python3-gi and python-gobject.

Okey, I will install those missing packages with the following command:

sudo apt-get install python-gi python3-gi python-gobject -y

But the unexpected thing is that my computer has already installed the packages. I advise you not to uninstall those packages and then reinstall them. It can destroy your operating system interface.

Start investigating the cause

At this point, I do not think my computer is missing any packages. I think the file that ran the ibus-setup command failed somehow and I started to investigate the problem.

I searched for the file named ibus-setup with the following command, you type this command if you do not know where the file.

sudo find / -name "ibus-setup"

And the result is the file located in the path /usr/bin/ibus-setup.

I use the following command to open the file, you can open it in any way that you know.

sudo nano /usr/bin/ibus-setup

When I open the file, I notice the exec command – this is the executable statement. I see that it calls python3.

Fix ImportError: No module named 'gi' in Mint 18
Change the path to python3 in ibus-setup file.

I started to think that my computer was fully loaded with both python2 and python3, so the high possibility that this command lacks the path to python3. So it can not execute the command as desired.

I changed the path to python3 in the file to /usr/bin/python3 and save the file and … boom !!! It already works. The error has disappeared and I can open Ibus Preferences.


The above is the process by which I have resolved the error ImportError: No module named ‘gi’ I encountered. I hope the experiences shared in this article will help you in some case.

(This is an article from my old blog that has been inactive for a long time, I don’t want to throw it away so I will keep it and hope it helps someone).

0 0 votes
Article Rating

You may also like

Notify of
Inline Feedbacks
View all comments

DevOps Lite is a personal blog specializing in technology with main topics about DevOps, DevSecOps, SRE and System Administrator. Articles are shared for free and contributed to the community.



Subscribe my Newsletter for new blog posts. Stay updated from your inbox!

© 2021-2024 – All rights reserved.

Please write sources “” when using articles from this website.

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Accept Read More

Would love your thoughts, please comment.x

Adblock Detected

Please support us by disabling your AdBlocker extension from your browsers for our website.