PySide2:DLL 加载失败:找不到指定的过程

PySide2: DLL load failed: The specified procedure could not be found

我正在尝试使用 Python 3.5.1 在 PySide2 中构建一个项目。以前,我在 PySide 中使用 Python 2.7 进行开发,但想升级到 Python 3。

我已经下载了 PySide2 (5.12.4) 并且我还下载了 Qt5 (5.13.0)(如果重要的话)。

然而,每当我尝试 运行 这个 hello world 程序时,我总是会收到这些完全相同的错误,我不知道从哪里开始修复。

我认为这个问题与 Shiboken 有关,但我不知道如何解决它。

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_())

我的错误是:

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.

更新:我最终使用 Python 3.7.3(最新版本)而不是 3.5.1,它现在可以与 PySide2 5.12.4 一起使用,它也是 PySide2 的最新版本

shiboken 包和我的 Python 版本肯定存在兼容性问题,所以使用两者的最新版本对我来说已经成功了。

我在使用 Python 3.8 并从今天开始安装 shiboken2 whl (5.14.0a1, 12-15-19) 时也发生了这种情况。使用 Python 3.7.5 让我消失了。

运行 pip freeze 获取有关已安装版本的信息并确保 PySide2shiboken2 的版本相同。

我使用 python 3.7.5 和

时发生了这种情况
PySide2==5.15.1
shiboken2==5.15.1

但是,情节扭曲:仅在 pytesting 时。正常执行脚本时,它们工作正常。

pytest==6.1.2

如果使用python3.8.0

我遇到了同样的问题,但对我来说 PySide2 和 shiboken2 版本是一样的。 (所以这里接受的答案不适合我。)

我有 python 版本 3.8.0 64 位。 事实证明,shiboken2 与 python 3.8.0 不兼容,所以我尝试升级到 python 3.8.7,问题消失了。 (它在 python 3.9.x 上也能正常工作,所以你也可以迁移到 python 3.9!)

注意:它也适用于 PySide6 和 shiboken6。