我试图用Python3.5.1在PySide2中构建一个项目。以前,我使用Python2.7在PySide中进行开发,但希望升级到Python3。
我下载了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.发布于 2020-03-24 14:22:24
运行pip freeze以获取有关已安装版本的信息,并确保PySide2和shiboken2的版本相同。
发布于 2019-06-25 17:56:48
更新:我最后使用了Python3.7.3(更新最多的版本),而不是3.5.1,现在它可以使用PySide2 5.12.4,这也是PySide2的最新版本
与shiboken包和我的Python版本之间一定存在兼容性问题,所以使用这两个版本的最新版本对我来说都很有用。
发布于 2019-12-15 17:46:44
在我使用Python3.8并从今天起安装了shiboken2 whl (5.14.0a1,12-15-19)时,我也遇到了这种情况。使用Python3.7.5使这件事对我来说消失了。
https://stackoverflow.com/questions/56757044
复制相似问题