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

Share this post to your friends !
  • 1

DanieBlog - 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-01 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-02 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.

If you liked this article, then please subscribe to our YouTube Channel for more video tutorials. You can also find us on Twitter and Facebook.

Share this post to your friends !
  • 1
If you appreciate what we share in this blog, you can support us by:
  1. Stay connected to: Facebook | Twitter | Google Plus | YouTube
  2. Subscribe email to recieve new posts from us: Sign up now.
  3. Start your own blog with SSD VPS - Free Let's Encrypt SSL ($2.5/month).
  4. Become a Supporter - Make a contribution via PayPal.
  5. Support us by purchasing Ribbon Lite Child theme being using on this website.

We are thankful for your support.

single post bottom banner
«« »»

Got something to say? Join the discussion

Please keep in mind that all comments are subject to our Comment Policy. Your email address will not be published.
This site uses Akismet to reduce spam. Learn how your comment data is processed.