Skip to content
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

"Failed to acquire X connection: Can't connect to display" #11

Open
maxcurrent420 opened this issue Jul 10, 2024 · 2 comments
Open

"Failed to acquire X connection: Can't connect to display" #11

maxcurrent420 opened this issue Jul 10, 2024 · 2 comments

Comments

@maxcurrent420
Copy link

Installed on Linux and after having to install a number of dependencies left out of the requirements.txt I got this error on startup:

/python3.10/site-packages/pynput/_util/__init__.py", line 77, in backend
    raise ImportError('this platform is not supported: {}'.format(
ImportError: this platform is not supported: ('failed to acquire X connection: Can\'t connect to display ":0": b\'Authorization required, but no authorization protocol specified\\n\'', DisplayConnectionError(':0', b'Authorization required, but no authorization protocol specified\n'))

Try one of the following resolutions:

 * Please make sure that you have an X server running, and that the DISPLAY environment variable is set correctly

Now, I don't know why I need an x server going, but more importantly how do I set it as an environment variable, assuming I get one on here? I just assumed once I installed it and got the llm going it would open a browser tab :D

@KoljaB
Copy link
Owner

KoljaB commented Jul 11, 2024

I wasn't aware this needs an X Server running on linux. Since pynput is used in linguflex only for keyboard input handling (specifically to listen for the Escape key press and abort TTS in that case) it's probably best to switch to another keyboard handler.

In lingu.py replace:

from pynput import keyboard

with

import keyboard

Then replace

self.listener = keyboard.Listener(on_press=self.on_press)
self.listener.start()

with

keyboard.on_press_key("esc", self.on_press)

And finally replace

    def on_press(self, key):
        """
        Function called when a key is pressed.
        If Escape key is pressed, a message is printed.
        """
        if key == keyboard.Key.esc:
            events.trigger("escape_key_pressed", "ui")
            return True

with

    def on_press(self, key):
        events.trigger("escape_key_pressed", "ui")

This should solve the problems.

@KoljaB
Copy link
Owner

KoljaB commented Jul 11, 2024

I committed the changes into the repo, the changed file is now here:

https://github.com/KoljaB/Linguflex/blob/main/lingu/core/lingu.py

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