Search code examples
pythonmacospyside6

ImportError: dlopen when running pyside6 app | Python


I am trying to run my app on mac, I got my whole code to an IMac;then, I installed all my libraries, but when I run it, it throws this error:

Traceback (most recent call last):
  File "~/main.py", line 8, in <module>
    from PySide6.QtWidgets import QApplication, QWidget
ImportError: dlopen(/Users/user/Desktop/~/venv/lib/python3.10/site-packages/PySide6/QtWidgets.abi3.so, 2): Symbol not found: _NSAppearanceNameDarkAqua
  Referenced from: /Users/user/Desktop/~/venv/lib/python3.10/site-packages/PySide6/Qt/lib/QtCore.framework/Versions/A/QtCore
  Expected in: /System/Library/Frameworks/AppKit.framework/Versions/C/AppKit
 in /Users/user/Desktop/~/venv/lib/python3.10/site-packages/PySide6/Qt/lib/QtCore.framework/Versions/A/QtCore

I searched it, but no luck. I am running on Python 3.10 and PySide 6.3, Can anyone help me?


Solution

  • According to [Apple.Developer]: NSAppearanceNameDarkAqua (emphasis is mine):

    macOS 10.14+

    So, this package is not compatible (too new) with your OS version. Either:

    • Upgrade OSX to Mojave (or later). This would be the recommended way

    • Use an older PySide6 package - try the oldest ([PyPI]: PySide6 6.0.0: pip install PySide6==6.0.0), but I doubt it would solve your issue as it's still too new (and it was probably built against libraries that export NSAppearanceNameDarkAqua)

      • Switch to a replacement package like [PyPI]: PySide2 (I think that one uses Qt5 under the hood)
      • Try building PySide6 (and most likely Qt6) locally, but that will be quite a painful process (even for an experienced developer)