Fix GEdit Plugin ‘External Tools’ Could Not Be Loaded Error


I'm using GEdit version 3.36.2 pre-installed with Ubuntu 20.04.1.
I wanted to enable the External Tools plugin of GEdit, but I'm unable to do so.

When I click on the External Tools option, I get ⛔ symbol.

Gedit preferences

When I close GEdit and reopen it, the option is turned off.

Gedit preferences

If I enable it, I'll again get the same ⛔ symbol.

How do I fix this issue?

Edit 1:
gir1.2-gtksource-3.0 was not installed when I asked this question. After jokerdino's suggestion in the Ask Ubuntu General Room, I installed gir1.2-gtksource-3.0 using this command: sudo apt install gir1.2-gtksource-3.0.

I noticed an error message after installing gir1.2-gtksource-3.0.

Error message in gedit

The plugin "External Tools" could not be loaded
An error occured: Plugin loader "python 3" was not found

I am not sure if I could see this error message before installing gir1.2-gtksource-3.0. Maybe I didn't place the mouse pointer on the symbol (for few seconds) the first time when I noticed the symbol or maybe it could be some other reason. I don't know.

jokerdino suggested me to open gedit from terminal and check if I got any specific error while turning on External Tools. I did get an error in the terminal.

** (gedit:14693): WARNING **: 20:21:59.976: Error initializing Python Plugin Loader: PyGObject initialization failed
ImportError: could not import gobject (error was: ModuleNotFoundError("No module named 'gi'"))

** (gedit:14693): WARNING **: 20:21:59.976: Please check the installation of all the Python related packages required by libpeas and try again

(gedit:14693): libpeas-WARNING **: 20:21:59.976: Loader 'python3' is not a valid PeasPluginLoader instance

I guess Python 3.8.2 was pre-installed with my Ubuntu installation. I wanted to upgrade to Python 3.8.3. So I followed the instructions mentioned in this website Install Python 3.8.3 in Ubuntu 20.04 LTS – TechPiezo.
At the end of the article, two suggestions were given. First is to replace (or overwrite) already installed version 3.8.2 of Python; second is to install Python v3.8.3 alongside the Python v3.8.2. I followed the first option.

Best Answer

You must and should rollback to default Python version, i.e., 3.8.2 in 20.04 since there are some libraries which are required by some packages installed in the system only for the default version of Python that may not be available or compatible with other versions. Since you've installed Python 3.8.3 from source, the files were copied in /usr/local/ and /usr/local/bin/python3 is created which a symlink, a.k.a, symbolic link or soft link, of /usr/local/bin/python3.8.

The default value of PATH contains /usr/local/bin before /usr/bin, thus given priority and the reason behind invoking Python 3.8.3 instead of 3.8.2 whenever python3 or python3.8 is called (since default Python is installed in /usr/bin).

To revert back to the default python3 won't take much time for you. You have 3 options to revert back.

  1. Removing the symlink: Just delete /usr/local/bin/python3. Yes that's it.

  2. Recreate symlink: You can make /usr/local/bin/python3 to point to /usr/bin/python3.8 or /usr/bin/python3 (which is already a symlink to /usr/bin/python3.8 as per your message in general room).

    To recreate symlink, use ln with s and f options, i.e.,

    sudo ln -sf /usr/bin/python3.8 /usr/local/bin/python3 # You may replace /usr/bin/python3.8 with /usr/bin/python3 as explained above
  3. Giving /usr/bin priority (overkill): Edit /etc/environment and place /usr/bin before /usr/local/bin.

    Warning!!! You should handle /etc/environment with care. Don't touch or do anything unless you know what you're doing.

    Alternatively, you can place PATH="/usr/bin:$PATH" in /.profile.

    Once done, logout and relogin to make changes take place.

Since you've installed Python 3.8.3 from source, you need to delete files manually as Python don't provide uninstall option for make. To delete them run:

# From /usr/local/bin
cd /usr/local/bin
sudo rm 2to3 2to3-3.8 easy_install-3.8 idle3 idle3.8 pip3 pip3.8 pydoc3 pydoc3.8 python3 python3.8 python3.8-config python3-config
# From /usr/local/include
sudo rm -r /usr/local/include/python3.8
# From /usr/local/lib
cd /usr/local/lib
sudo rm -r libpython3.8.a pkgconfig python3.8
# From /usr/local/man/man1
cd /usr/local/man/man1
sudo rm -r python3.1 python3.8.1
# From /usr/local/share/man/man1
cd /usr/local/share/man/man1
sudo rm -r python3.1 python3.8.1
Related Question