That didnt answer the main question - did you use sudo with one of those python package managers at some point?
Well that, and, the general question around this:
Your virtual environments are where you should do your development thingsā¦
We are technically not interested in how gnome-tweaks functions there ā¦ we care more about regular use - āoutside ofā those environments.
(However you abuse your virtual environment is up to you. If you break it make a new one.)
You already have python-gobject installed as a dependency of gnome-tweaks, but since you installed Python packages locally instead of setting up a virtual environment, itās looking for it there.
Did I modify my Python with pip outside a virtual environment? Maybe.
Trying now to modify, I get the neat error message:
alba@mac2011-manjaro% pip install gi
error: externally-managed-environment
Ć This environment is externally managed
ā°ā> To install Python packages system-wide, try 'pacman -S
python-xyz', where xyz is the package you are trying to
install.
So I doubt I modified, unless the security net was installed very recently.
I try this
alba@mac2011-manjaro% sudo pacman -S python-gobject
warning: python-gobject-3.46.0-1 is up to date -- reinstalling
No improvement.
I donāt see how I could break the Python used by Gnome.
By not caring about signing in as root and then running pip install, maybe ?
(or ā¦ something similar. That only comes to mind because of the things mentioned here.)
I logged as root just to launch Tweaks in Activities. I normally never do this.
Now, if I do
/usr/bin/python -c 'import gi'
I have no error, while I have the gi error in Logs if I launch Tweaks from Activities.
This shows that Gnome does not use the same Python that is availabe to me.
From /usr/bin/gnome-tweaks :
import gi
gi.require_version("Gtk", "3.0")
gi.require_version("Handy", "1")
I/usr/bin/gnome-tweaks works in Terminal (after exiting any custom env). Thus Python is not broken.
Something is broken in my session but it is not Python. It is something that disturbs the way Python is called.
In Logs, maybe related:
ImportError: cannot import name '_gi' from partially initialized module
File "/usr/lib/python3.11/site-packages/gi/__init.py__", line 40
Fule "/usr/lib/lollypop/lollypop-sp", line 19
I have improved something: I could make the MyTweaks launcher work with
Exec=/usr/bin/python /usr/bin/gnome-tweaks
hence it may be just a path-to-Python problem, caused by miniconda, that I had installed with Add/Remove software (AUR).
miniconda3 disturbs Python path, in Terminal and Activities.
This can be avoided in Terminal with conda deactivate and in Activities by uninstalling miniconda3 or less radically by copying /usr/share/applications/org.gnome.tweaks.desktop to ~/.local/share/applications/mytweaks.desktop and replacing in the new file Exec=gnome-tweaks by Exec=/usr/bin/python /usr/bin/gnome-tweaks.
In Activities, search Tweaks and click the second icon.