Fixing GNOME Terminal Python Import Error | Generated by AI
Issue Diagnosis
Your GNOME Terminal is failing to launch due to a Python import error in the GObject Introspection (GI) library. The traceback shows it’s choking on from gi.repository import GLib, Gio
, specifically at line 40 in /usr/lib/python3/dist-packages/gi/__init__.py
. The full error (based on common reports) is likely:
ImportError: cannot import name '_gi' from partially initialized module 'gi' (most likely due to a circular import)
This typically happens because of a mismatch between your system’s Python version and the GI bindings (python3-gi package), often after manual Python upgrades, virtual environments, or package corruption. The UFW BLOCK logs in your journalctl output are unrelated—they’re just your firewall dropping harmless multicast traffic (e.g., mDNS/UPnP discovery from other devices on 192.168.1.x). Ignore those for now.
Quick Fixes to Try
Since you already have a working shell prompt (looks like you’re in ~/projects
), you can run these commands directly. Start with the simplest:
- Reinstall the GI package and GNOME Terminal (most common fix):
sudo apt update sudo apt install --reinstall python3-gi gir1.2-glib-2.0 gnome-terminal
Then test by running
gnome-terminal
from your current shell. - If that doesn’t work, check/fix Python symlinks (if you recently tinkered with Python versions):
- Verify your system Python:
ls -l /usr/bin/python3
(should point to something like python3.10 or 3.12, depending on your distro version). - If it’s broken, reinstall the default Python:
sudo apt install --reinstall python3-minimal
- Or manually set the symlink (replace
3.10
with your distro’s default):sudo ln -sf /usr/bin/python3.10 /usr/bin/python3
- Verify your system Python:
- Full GNOME reset (if the above fails—resets terminal prefs but not data):
dconf reset -f /org/gnome/terminal/ gnome-terminal --reset-config
- Nuclear option: Purge and reinstall GNOME Terminal:
sudo apt purge gnome-terminal sudo apt install gnome-terminal
After any fix, log out/in or reboot to ensure the desktop environment picks it up. If you’re on Ubuntu/Debian-based (guessing from paths), these should work. If it’s another distro (e.g., Fedora), swap apt
for dnf
.
If none of this resolves it, run python3 -c "from gi.repository import GLib; print('OK')"
in your current shell and share the output for more clues.
References
- Gnome terminal will not start after trying to install newer version of Python
- Why won’t terminal open?
- ImportError: cannot import name ‘_gi’ from partially initialized module
- Some applications not working on Zorin 17 Core