pynputdlsym

Error while importing pynput - dlsym(0x7f90f7d0c310, PyObjCObject_New): symbol not found


I installed pynput module (version 1.7.4) using this command: pip3 install pynput

I tried to import the module in my Jupyter-lab, which always ended up a failure. The error message looks like this:

AttributeError: dlsym(0x7f90f7d0c310, PyObjCObject_New): symbol not found

I tried to find previous questions but could not find one that could help me solve this issue. If someone can help me with dealing with this issue, that would be highly appreciated.

Just in case it would be necessary to figure out my issue, the entire error message is attached below:

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
/var/folders/l3/gg_2y0zx4zz2rqytp5sctpy80000gn/T/ipykernel_64397/3885633262.py in <module>
----> 1 import pynput

~/opt/anaconda3/envs/GE/lib/python3.9/site-packages/pynput/__init__.py in <module>
     38 
     39 
---> 40 from . import keyboard
     41 from . import mouse

~/opt/anaconda3/envs/GE/lib/python3.9/site-packages/pynput/keyboard/__init__.py in <module>
     29 
     30 
---> 31 backend = backend(__name__)
     32 KeyCode = backend.KeyCode
     33 Key = backend.Key

~/opt/anaconda3/envs/GE/lib/python3.9/site-packages/pynput/_util/__init__.py in backend(package)
     68     for module in modules:
     69         try:
---> 70             return importlib.import_module('._' + module, package)
     71         except ImportError as e:
     72             errors.append(e)

~/opt/anaconda3/envs/GE/lib/python3.9/importlib/__init__.py in import_module(name, package)
    125                 break
    126             level += 1
--> 127     return _bootstrap._gcd_import(name[level:], package, level)
    128 
    129 

~/opt/anaconda3/envs/GE/lib/python3.9/site-packages/pynput/keyboard/_darwin.py in <module>
     49     NSSystemDefined)
     50 
---> 51 from pynput._util.darwin import (
     52     get_unicode_to_keycode_map,
     53     keycode_context,

~/opt/anaconda3/envs/GE/lib/python3.9/site-packages/pynput/_util/darwin.py in <module>
     58 OBJC = ctypes.PyDLL(objc._objc.__file__)
     59 
---> 60 OBJC.PyObjCObject_New.restype = ctypes.py_object
     61 OBJC.PyObjCObject_New.argtypes = [ctypes.c_void_p, ctypes.c_int, ctypes.c_int]
     62 

~/opt/anaconda3/envs/GE/lib/python3.9/ctypes/__init__.py in __getattr__(self, name)
    393         if name.startswith('__') and name.endswith('__'):
    394             raise AttributeError(name)
--> 395         func = self.__getitem__(name)
    396         setattr(self, name, func)
    397         return func

~/opt/anaconda3/envs/GE/lib/python3.9/ctypes/__init__.py in __getitem__(self, name_or_ordinal)
    398 
    399     def __getitem__(self, name_or_ordinal):
--> 400         func = self._FuncPtr((name_or_ordinal, self))
    401         if not isinstance(name_or_ordinal, int):
    402             func.__name__ = name_or_ordinal

AttributeError: dlsym(0x7f90f7d0c310, PyObjCObject_New): symbol not found

Solution

  • https://github.com/moses-palmer/pynput/issues/420

    The latest Pyobjc breaks pynput. Downgrading it to 7.3 fixes this issue.