thp / pyotherside

Python Bindings for Qt 5 and Qt 6. Allows you to access a CPython 3 interpreter directly from your Qt QML user interface code.
https://thp.io/2011/pyotherside/
Other
364 stars 49 forks source link

addImportPath with qrc paths broken #123

Open wasular opened 3 years ago

wasular commented 3 years ago

I am currently trying to run pyotherside in a project on MacOs Monteray and QT 5.15.2 but I can't quite get this specific issue solved ... anyone here an idea ... On Windows and Linux it runs like a charm

Python Version via pyenv 3.9.6

Got library name:  "/opt/homebrew/Cellar/qt@5/5.15.2_1/qml/io/thp/pyotherside/libpyothersideplugin.dylib"
qml: Added Handler
"PyOtherSide error: Traceback (most recent call last):

  File \"<frozen importlib._bootstrap>\", line 919, in _find_spec
AttributeError: 'PyOtherSideQtRCImporter' object has no attribute 'find_spec'

During handling of the above exception, another exception occurred:

ImportError: PyCapsule_Import could not import module \"datetime\"

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File \"<frozen importlib._bootstrap>\", line 1007, in _find_and_load
  File \"<frozen importlib._bootstrap>\", line 982, in _find_and_load_unlocked
  File \"<frozen importlib._bootstrap>\", line 921, in _find_spec
  File \"<frozen importlib._bootstrap>\", line 895, in _find_spec_legacy
  File \"qrc://io/thp/pyotherside/qrc_importer.py\", line 26, in find_module
  File \"qrc://io/thp/pyotherside/qrc_importer.py\", line 38, in get_filename
SystemError: <built-in function qrc_is_file> returned a result with an error set

Unhandled PyOtherSide error: Cannot import module: bridge (Traceback (most recent call last):

  File "<frozen importlib._bootstrap>", line 919, in _find_spec

AttributeError: 'PyOtherSideQtRCImporter' object has no attribute 'find_spec'`
wasular commented 3 years ago

The issue seems to be clearly around putting a qrc path into addImportPath , trying to figure out how to circumvent this but since general python libs seem to work it is probably not directly related to the ARM processor architecture

thp commented 1 year ago

Looks like _find_spec / find_spec has been added in Python 3.4?

https://docs.python.org/3/library/importlib.html#importlib.abc.MetaPathFinder.find_spec

Are you sure you have the right bundled/frozen importlib/standard library?