arsenetar / send2trash

Python library to natively send files to Trash (or Recycle bin) on all platforms.
BSD 3-Clause "New" or "Revised" License
275 stars 44 forks source link

Crash on import `AttributeError: dlsym(RTLD_DEFAULT, GetMacOSStatusCommentString): symbol not found` #85

Open TheMatt2 opened 1 year ago

TheMatt2 commented 1 year ago

Description

On trying to install this module on Python 3.7, I immediately see an error message on import that is preventing the module from working.

Installed package from:

python3.7 -m pip install send2trash

I realize Python 3.7 is quite old, but I'm mainly writing this report to record this issue.

% python3
Python 3.7.3 (v3.7.3:ef4ec6ed12, Mar 25 2019, 16:52:21) 
[Clang 6.0 (clang-600.0.57)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from send2trash import send2trash
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/send2trash/mac/__init__.py", line 14, in <module>
    from send2trash.mac.modern import send2trash
  File "/usr/local/lib/python3.7/site-packages/send2trash/mac/modern.py", line 7, in <module>
    from Foundation import NSFileManager, NSURL
ModuleNotFoundError: No module named 'Foundation'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.7/site-packages/send2trash/__init__.py", line 12, in <module>
    from send2trash.mac import send2trash
  File "/usr/local/lib/python3.7/site-packages/send2trash/mac/__init__.py", line 17, in <module>
    from send2trash.mac.legacy import send2trash
  File "/usr/local/lib/python3.7/site-packages/send2trash/mac/legacy.py", line 18, in <module>
    GetMacOSStatusCommentString = Foundation.GetMacOSStatusCommentString
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/ctypes/__init__.py", line 369, in __getattr__
    func = self.__getitem__(name)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/ctypes/__init__.py", line 374, in __getitem__
    func = self._FuncPtr((name_or_ordinal, self))
AttributeError: dlsym(RTLD_DEFAULT, GetMacOSStatusCommentString): symbol not found
>>> 

OS: MacOS 12.7 Python: 3.7 Version: Send2Trash==1.8.2

TheMatt2 commented 1 year ago

Possibly related to #51

TheMatt2 commented 1 year ago

I tried using an install recommended in https://github.com/arsenetar/send2trash/issues/51#issuecomment-858111428

python3 -m pip install pyobjc-framework-Cocoa==7.3 send2trash==1.7.0a1

Now I get a different error:

% python3
Python 3.7.3 (v3.7.3:ef4ec6ed12, Mar 25 2019, 16:52:21) 
[Clang 6.0 (clang-600.0.57)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import send2trash
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.7/site-packages/send2trash/__init__.py", line 12, in <module>
    from .plat_osx import send2trash
  File "/usr/local/lib/python3.7/site-packages/send2trash/plat_osx.py", line 14, in <module>
    from .plat_osx_pyobjc import send2trash
  File "/usr/local/lib/python3.7/site-packages/send2trash/plat_osx_pyobjc.py", line 7, in <module>
    from Foundation import NSFileManager, NSURL
  File "/usr/local/lib/python3.7/site-packages/Foundation/__init__.py", line 9, in <module>
    import CoreFoundation
  File "/usr/local/lib/python3.7/site-packages/CoreFoundation/__init__.py", line 28, in <module>
    import CoreFoundation._CoreFoundation  # isort:skip  # noqa: E402
RuntimeError: Wrong version of PyObjC C API (got 25, expected 21)
paulgrow-octane commented 3 months ago

@TheMatt2 try using a different version of the pyobjc-framework-Cocoa library. I was running into the same issues as you and using the latest release resolved it for me.