3

I am trying to build a project in PySide2 with Python 3.5.1. Previously, I was developing in PySide with Python 2.7 but wanted to upgrade to Python 3.

I have downloaded PySide2 (5.12.4) and I also have Qt5 (5.13.0) downloaded (if that matters).

However, whenever I try to run this hello world program, I keep getting these same exact errors, that I don't know where to start to fix.

I think the issue has to do with Shiboken but I have no idea how to fix it.

import sys
from PySide2.QtWidgets import QApplication, QDialog, QLineEdit, QPushButton

class Form(QDialog):
    def __init__(self, parent=None):
        super(Form, self).__init__(parent)
        self.setWindowTitle("My Form")

if __name__ == '__main__':
    # Create the Qt Application
    app = QApplication(sys.argv)
    # Create and show the form
    form = Form()
    form.show()
    # Run the main Qt loop
    sys.exit(app.exec_())

And my errors are:

Traceback (most recent call last):
  File "C:/Users/user1/Documents/program_folder/hello.py", line 2, in <module>
    from PySide2.QtWidgets import QApplication, QDialog, QLineEdit, QPushButton

  File "C:\Users\user1\venv\program_folder\lib\site-packages\PySide2\__init__.py", line 51, in <module>
    _setupQtDirectories()

  File "C:\Users\user1\venv\program_folder\lib\site-packages\PySide2\__init__.py", line 21, in _setupQtDirectories
    import shiboken2

  File "C:\Users\user1\venv\program_folder\lib\site-packages\shiboken2\__init__.py", line 27, in <module>
    from .shiboken2 import *

ImportError: DLL load failed: The specified procedure could not be found.
papers1010
  • 135
  • 1
  • 1
  • 8

5 Answers5

4

Update: I ended up using Python 3.7.3 (the most updated version) instead of 3.5.1 and it now works with PySide2 5.12.4 which is also the most updated version of PySide2

There must have been compatibility issues with the shiboken package and my Python version, so using the most updated versions of both has done the trick for me.

papers1010
  • 135
  • 1
  • 1
  • 8
2

This also happened to me while I was using Python 3.8 and installed the shiboken2 whl from today (5.14.0a1, 12-15-19). Using Python 3.7.5 made this go away for me.

BigRed118
  • 131
  • 1
  • 6
  • 1
    Seems to happen with Python3.8.0 and release version of PySide2 5.14.0 (19.12.2019) as well. With Python3.8.1 and the same PySide version it seems to work, although some Qt internal error messages are printed. (Platform Win7x64) – timmwagener Dec 21 '19 at 17:44
2

Run pip freeze to get information about the installed versions and make sure that PySide2 and shiboken2 are of the same version.

wedesoft
  • 2,781
  • 28
  • 25
1

This is happening to me with python 3.7.5 and

PySide2==5.15.1
shiboken2==5.15.1

but, plot twist: ONLY when pytesting. When executing the scripts normally, they just work fine.

pytest==6.1.2
pietro
  • 41
  • 3
1

If you use python 3.8.0

I had the same problem, but for me the PySide2 and shiboken2 versions where the same. (So the accepted answer here didn't work out for me.)

I had python version 3.8.0 64-bit. It turns out that shiboken2 was incompatible with python 3.8.0, so I tried upgrading to python 3.8.7 and the problem went away. (It also works fine on python 3.9.x so you can as well just migrate to python 3.9!)

note: It also works for PySide6 and shiboken6.

  • 1
    Can confirm this worked: I had python 3.8.0 and upgraded in-place to 3.8.10 (on windows, it's the latest 3.8 with an installer), then ran `python -m venv --upgrade my/venv` to update my virtual environment and it worked. – ARDVL Oct 01 '22 at 09:35
  • I'm using `pyside6` and `shiboken6` version 6.3.2. – ARDVL Oct 01 '22 at 09:45