clawjelly
clawjelly

Reputation: 47

ImportError with PySide6/shiboken6

I'm trying to get PySide6 to run in Python 3.8.0. Installation went fine:

C:\>pip install pyside6
Collecting pyside6
  Using cached PySide6-6.0.0-6.0.0-cp36.cp37.cp38.cp39-none-win_amd64.whl (62.4 MB)
Collecting shiboken6==6.0.0
  Using cached shiboken6-6.0.0-6.0.0-cp36.cp37.cp38.cp39-none-win_amd64.whl (2.3 MB)
Installing collected packages: shiboken6, pyside6
Successfully installed pyside6-6.0.0 shiboken6-6.0.0

but i'm hit with an import error:

Python 3.8.0 (tags/v3.8.0:fa919fd, Oct 14 2019, 19:37:50) [MSC v.1916 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import PySide6
PySide6/__init__.py: Unable to import shiboken6 from , C:\Python38\python38.zip, C:\Python38\DLLs, C:\Python38\lib, C:\Python38, C:\Python38\lib\site-packages
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Python38\lib\site-packages\PySide6\__init__.py", line 107, in <module>
    _setupQtDirectories()
  File "C:\Python38\lib\site-packages\PySide6\__init__.py", line 57, in _setupQtDirectories
    import shiboken6
  File "C:\Python38\lib\site-packages\shiboken6\__init__.py", line 25, in <module>
    from .shiboken6 import *
ImportError: DLL load failed while importing shiboken6: The specified procedure could not be found.

What did i do wrong?

Upvotes: 1

Views: 3393

Answers (1)

adam.hendry
adam.hendry

Reputation: 5625

What did i do wrong?

I don't believe you did anything wrong.

I think this was a known bug in shiboken6 versions <=6.0.0. It was reported partly in the PySide bug tracker: PYSIDE-932.

The issue appeared to be that they were attempting to import from a zip file. From the comments in version 6.3.0 of shiboken6.__init__:

# PYSIDE-932: Python 2 cannot import 'zipfile' for embedding while being imported, itself.
# We simply pre-load all imports for the signature extension.
# Also, PyInstaller seems not always to be reliable in finding modules.
# We explicitly import everything that is needed:

The comment says Python 2 cannot import, but it should read PySide2 cannot import because the issue came from Python 3.6 using PySide 2.

The Qt Docs mention using a newer version of virtualenv to fix this problem, but I do not believe virtualenv is the culprit. Moreover, the latest Python 3 versions ship with and use venv. Instead, I believe this was an issue with importing zip files. It may have been resolved when Barry Warsaw/Brett Cannon and their team introduced importlib.resources in newer versions of Python 3, which can particularly help with zip files.

See their talk here:

Barry Warsaw - Get your resources faster, with importlib.resources - PyCon 2018

Ultimately, I believe this was resolved in the latest version of shiboken6 (i.e. 6.3.0).

Give that a try and see if that works.

Upvotes: 3

Related Questions