Skip to content

ValueError: Namespace Gtk not available with --no-gui #41

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
dieck opened this issue Jul 25, 2022 · 1 comment
Closed

ValueError: Namespace Gtk not available with --no-gui #41

dieck opened this issue Jul 25, 2022 · 1 comment

Comments

@dieck
Copy link

dieck commented Jul 25, 2022

Hi!

I am trying to run emailproxy on a "headless" Linux VM (Ubuntu Server)

It seems even with --no-gui, it tries to load Gtk:

python emailproxy.py --no-gui --local-server-auth
Traceback (most recent call last):
File "emailproxy.py", line 39, in
import pystray
File "/usr/local/lib/python3.8/dist-packages/pystray/init.py", line 64, in
Icon = backend().Icon
File "/usr/local/lib/python3.8/dist-packages/pystray/init.py", line 56, in backend
return candidate()
File "/usr/local/lib/python3.8/dist-packages/pystray/init.py", line 28, in appindicator
from . import _appindicator as backend; return backend
File "/usr/local/lib/python3.8/dist-packages/pystray/_appindicator.py", line 19, in
gi.require_version('Gtk', '3.0')
File "/usr/lib/python3/dist-packages/gi/init.py", line 129, in require_version
raise ValueError('Namespace %s not available' % namespace)
ValueError: Namespace Gtk not available

My "quick and dirty" solution:
I moved the "import pystray" to the "else" part of "if self.args.no_gui" around line 1515.

I have not tested if this now works with gui-enabled installations.
And for a proper solution, you might want to look if there is a better placement, or if other libraries are needed to be handled similar as well?

Best regards,
Marco

@simonrob
Copy link
Owner

The proxy was primarily designed for use with a GUI, so while the sort of change you propose does indeed work, I currently prefer the route suggested in the readme, which points to this previous discussion. Essentially, you set an environment variable to direct pystray not to try loading any GUI toolkit. If that doesn't work I'd be happy to look at alternatives, but for now I think it's the best way to go.

simonrob added a commit that referenced this issue Aug 24, 2022
Simplifies installation in headless / no-GUI environments (see, e.g., #1, #2, #11, #41, #45, 48, #49, #54, #55)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants