moses-palmer / pynput

Sends virtual input commands
GNU Lesser General Public License v3.0
1.79k stars 248 forks source link

AttributeError: dlsym(0x7ff8574b4550, PyObjCObject_New): symbol not found #420

Closed aleform closed 2 years ago

aleform commented 2 years ago

I cannot import the module on my Mac m1 Big Sur. This is the error I get.

import pynput
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/pynput/__init__.py", line 40, in <module>
    from . import keyboard
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/pynput/keyboard/__init__.py", line 31, in <module>
    backend = backend(__name__)
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/pynput/_util/__init__.py", line 70, in backend
    return importlib.import_module('._' + module, package)
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/pynput/keyboard/_darwin.py", line 51, in <module>
    from pynput._util.darwin import (
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/pynput/_util/darwin.py", line 60, in <module>
    OBJC.PyObjCObject_New.restype = ctypes.py_object
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/ctypes/__init__.py", line 387, in __getattr__
    func = self.__getitem__(name)
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/ctypes/__init__.py", line 392, in __getitem__
    func = self._FuncPtr((name_or_ordinal, self))
AttributeError: dlsym(0x7ff8574b4550, PyObjCObject_New): symbol not found
QingRebecca commented 2 years ago

Any news? I have the same problem with Mac OS Monterey (M1 Pro chip)

anthonyaoun23 commented 2 years ago

Me as well, on a macbook pro 2015 Mac OS Monterey. No luck finding a fix yet, but same exact error.

Pedro-Beirao commented 2 years ago

It was working fine yesterday, but I decided to upgrade from 1.7.3 to 1.7.4, and not I get this error Tried downgrading, but the problem doesnt go away.

MacOS Monterey - M1 MacBook pro

Pedro-Beirao commented 2 years ago

I think the problem is that pyobjc (https://github.com/ronaldoussoren/pyobjc) was updated a few days ago. I will write back if I get it to work

aleform commented 2 years ago

Thanks @Pedro-Beirao! The problem is pyojc I downgraded to 7.3 and seems to work

Pedro-Beirao commented 2 years ago

Downgrading pyobjc to 7.3 also worked for me

moses-palmer commented 2 years ago

Thank you for your report.

I can reproduce this on a non-M1 mac, and it seems to be caused by changes to pyobjc. I hade made a small change and pushed the fix to master.

markthompson94 commented 2 years ago

After downgrading pyobjc to 7.3, I get the below error;

  File "/Users/xxxxxxxxx/xxxx/xxxxx/lib/python3.8/site-packages/HIServices/init.py", line 11, in     from HIServices import _metadata, _HIServices RuntimeError: Wrong version of PyObjC C API (got 21, expected 22)

Has anyone else seen this / does any have a solution?

Are there modules with dependencies on PyObjC that also require downgrading?

Thanks, Mark

moses-palmer commented 2 years ago

Please try the updated version of pynput instead; install from the master branch.

markthompson94 commented 2 years ago

Do you know when we might be able to expect the fix included in a PyPi release?

Thanks, Mark

willwade commented 2 years ago

Just to save anyone else the google:

pip install --upgrade pyobjc==7.3

Fixes this

JeremyKeusters commented 1 year ago

In case anyone still bumps into this, simply upgrading to pynput==1.7.6 does the trick now.