Open bryanhughes opened 8 months ago
This appears to be happening because I am using the machine remotely and accessing via ssh -X ...
Thank you for your report.
I notice that your Xlib bindings appear to come from site-packages/Xlib
whereas the declared dependencies for this library include python_xlib
. Could this be the reason for the unexpected error when running over SSH? Then again, this X extension is hopefully not exposed over SSH anyway.
I ran into the same problem. I am running over SSH like ssh -X ...
, and I also noticed that my Xlib bindings are coming from site-packages/Xlib
.
But I just realized that the library module of python-xlib is actually Xlib
- like the folder name is actually Xlib
(see in the python-xlib repo) so that seems to be correct... I am not sure how to proceed from here... Any hints?
It seems that that attribute is present only when the RECORD extension is loaded by the XServer. The method record_create_context
is appended to the display object at Xlib/ext/record.py
. I saw that for me this extension is not "loaded" or not there. To print it, I ran xdpyinfo -display :10 -queryExtensions
. My list of extensions are:
number of extensions: 22
Apple-DRI (opcode: 129, base event: 64, base error: 128)
Apple-WM (opcode: 130, base event: 68, base error: 130)
BIG-REQUESTS (opcode: 135)
DAMAGE (opcode: 143, base event: 98, base error: 156)
DOUBLE-BUFFER (opcode: 145, base error: 157)
GLX (opcode: 149, base event: 102, base error: 161)
Generic Event Extension (opcode: 131)
MIT-SCREEN-SAVER (opcode: 144, base event: 99)
MIT-SHM (opcode: 133, base event: 72, base error: 132)
Present (opcode: 146)
RANDR (opcode: 142, base event: 96, base error: 151)
RENDER (opcode: 141, base error: 146)
SECURITY (opcode: 139, base event: 93, base error: 142)
SHAPE (opcode: 132, base event: 71)
SYNC (opcode: 136, base event: 90, base error: 138)
X-Resource (opcode: 147)
XC-MISC (opcode: 138)
XFIXES (opcode: 140, base event: 94, base error: 144)
XINERAMA (opcode: 128)
XInputExtension (opcode: 134, base event: 73, base error: 133)
XKEYBOARD (opcode: 137, base event: 92, base error: 141)
XVideo (opcode: 148, base event: 100, base error: 158)
I am still looking at it to see how to enable that. If you know how to do it, I'd be glad to hear, so I can test it. I was wondering if we really need to rely on the record extension to make pynput work. Could we rely only oin the XKeyboard and XInputExtension?
Any follow-up on this?
Any resolution to this issue? I am using the robosuite package - https://robosuite.ai - and want to control the simulation robot. My images are rendered thru the ssh connection when I log in using -XY flags, but when I used my keyboard to move the sim robot it does not work in an ssh session. However, it works when I go to the physical machine and try it out. Detailed error is below -
Traceback (most recent call last):
File "/home/megh/projects/venv_envs/mimicgen/lib/python3.8/site-packages/Xlib/display.py", line 224, in __getattr__
function = self.display_extension_methods[attr]
KeyError: 'record_create_context'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/lib/python3.8/threading.py", line 932, in _bootstrap_inner
self.run()
File "/home/megh/projects/venv_envs/mimicgen/lib/python3.8/site-packages/pynput/_util/__init__.py", line 211, in run
self._run()
File "/home/megh/projects/venv_envs/mimicgen/lib/python3.8/site-packages/pynput/keyboard/_xorg.py", line 559, in _run
super(Listener, self)._run()
File "/home/megh/projects/venv_envs/mimicgen/lib/python3.8/site-packages/pynput/_util/xorg.py", line 386, in _run
self._context = dm.record_create_context(
File "/home/megh/projects/venv_envs/mimicgen/lib/python3.8/site-packages/Xlib/display.py", line 227, in __getattr__
raise AttributeError(attr)
AttributeError: record_create_context
Description I am trying to use pynput and getting the exception
AttributeError: record_create_context
Platform and pynput version
To Reproduce Unfortunately my problem is a little more complex. I have a
SoundRecorder
class that has a threaded function that does the actual recording. Here is themain
block of code. I don't understand this exception.The full stack trace