mooz / xkeysnail

Yet another keyboard remapping tool for X environment
891 stars 112 forks source link

Installation issue #125

Open gk2803 opened 3 years ago

gk2803 commented 3 years ago

OS: Ubuntu 20.10 python version: 3.8

tried installng both from source code and pip but get this error when running sudo xkeysnail config.py


Traceback (most recent call last):
  File "/usr/local/bin/xkeysnail", line 6, in <module>
    cli_main()
  File "/usr/local/lib/python3.8/dist-packages/xkeysnail/__init__.py", line 62, in cli_main
    eval_file(args.config)
  File "/usr/local/lib/python3.8/dist-packages/xkeysnail/__init__.py", line 5, in eval_file
    with open(path, "rb") as file:
FileNotFoundError: [Errno 2] No such file or directory: 'config.py'
Exception ignored in: <function InputDevice.__del__ at 0x7fe8685e1310>
Traceback (most recent call last):
  File "/usr/local/lib/python3.8/dist-packages/evdev/device.py", line 160, in __del__
  File "/usr/local/lib/python3.8/dist-packages/evdev/device.py", line 305, in close
  File "/usr/local/lib/python3.8/dist-packages/evdev/eventio_async.py", line 55, in close
  File "/usr/lib/python3.8/asyncio/events.py", line 722, in get_event_loop_policy
  File "/usr/lib/python3.8/asyncio/events.py", line 715, in _init_event_loop_policy
ImportError: sys.meta_path is None, Python is likely shutting down
luizoti commented 3 years ago

First, check if your config.py file exist ---> No such file or directory: 'config.py'

I suppose the error: ImportError: sys.meta_path is None, Python is likely shutting down, happens as a result of the error: FileNotFoundError: [Errno 2] No such file or directory: 'config.py'.

I believe that error ImportError: sys.meta_path is None, Python is likely shutting down should happen in certain situations, where the other error occurs during execution.

luizoti commented 3 years ago

I submit this PR: 154 to evdev repo, probably will fix the ImportError: sys.meta_path is None, Python is likely shutting down.

But your problem is missing config.py.

CSpencerND commented 3 years ago

I'm getting the same errors even though I have my config file

Traceback (most recent call last):
  File "/usr/local/bin/xkeysnail", line 6, in <module>
    cli_main()
  File "/usr/local/lib/python3.9/dist-packages/xkeysnail/__init__.py", line 62, in cli_main
    eval_file(args.config)
  File "/usr/local/lib/python3.9/dist-packages/xkeysnail/__init__.py", line 6, in eval_file
    exec(compile(file.read(), path, 'exec'), globals())
  File "/home/cs/.config/xkeysnail/config.py", line 2, in <module>
    from xkeysnail.transform import *
  File "/usr/local/lib/python3.9/dist-packages/xkeysnail/transform.py", line 16, in <module>
    def get_active_window_wm_class(display=Xlib.display.Display()):
  File "/usr/lib/python3/dist-packages/Xlib/display.py", line 89, in __init__
    self.display = _BaseDisplay(display)
  File "/usr/lib/python3/dist-packages/Xlib/display.py", line 71, in __init__
    protocol_display.Display.__init__(self, *args, **keys)
  File "/usr/lib/python3/dist-packages/Xlib/protocol/display.py", line 166, in __init__
    raise error.DisplayConnectionError(self.display_name, r.reason)
Xlib.error.DisplayConnectionError: Can't connect to display ":1": b'No protocol specified\n'
Exception ignored in: <function InputDevice.__del__ at 0x7f8a2b5b7940>
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/evdev/device.py", line 160, in __del__
  File "/usr/lib/python3/dist-packages/evdev/device.py", line 305, in close
  File "/usr/lib/python3/dist-packages/evdev/eventio_async.py", line 55, in close
  File "/usr/lib/python3.9/asyncio/events.py", line 725, in get_event_loop_policy
  File "/usr/lib/python3.9/asyncio/events.py", line 718, in _init_event_loop_policy
ImportError: sys.meta_path is None, Python is likely shutting down
luizoti commented 3 years ago

In your case the real error is:

Xlib.error.DisplayConnectionError: Can't connect to display ":1": b'No protocol specified\n'

In general, any error raised by Xkeysnail will return similar errors, like this:


Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/evdev/device.py", line 160, in __del__
  File "/usr/lib/python3/dist-packages/evdev/device.py", line 305, in close
  File "/usr/lib/python3/dist-packages/evdev/eventio_async.py", line 55, in close
  File "/usr/lib/python3.9/asyncio/events.py", line 725, in get_event_loop_policy
  File "/usr/lib/python3.9/asyncio/events.py", line 718, in _init_event_loop_policy
ImportError: sys.meta_path is None, Python is likely shutting down```
luizoti commented 3 years ago

How was Xkey chosen? Because he is not able to access the DISPLAY

CSpencerND commented 3 years ago

Interesting. I'm not sure what you mean by "chosen". I installed with pip. Made the config file, and ran it with sudo xkeysnail ~/.config/xkeysnail/config.py. I'm on a laptop with no extra display connected.

luizoti commented 3 years ago

I also don't know where the word 'chosen' came from. haha

I'm not talking about monitors, but about DISPLAY, maybe that explains it better: display

I had the same problem running xkeysnail through a systemd service.

CSpencerND commented 3 years ago

It's works after running xhost +. Thanks very much.

joshgoebel commented 2 years ago

@gk2803 Did you get this working?

gk2803 commented 2 years ago

nope

luizoti commented 2 years ago

nope

This error?

ImportError: sys.meta_path is None, Python is likely shutting down