升级Pyside6后,错误没有名为' pyside6.qtwidgets'
升级到pyside6.3.0后,获得错误 modulenotfounderror:no模块名为“ Pyside6.qtwidgets'
源>源>源
import sys
from PySide6.QtWidgets import QApplication, QLabel
app = QApplication(sys.argv)
label = QLabel("Hello World!")
label.show()
app.exec()
错误:
$ python3.10 test.py
Traceback (most recent call last):
File "test.py", line 2, in <module>
from PySide6.QtWidgets import QApplication, QLabel
ModuleNotFoundError: No module named 'PySide6.QtWidgets'
似乎在 pyside6.3.0
中似乎存在更改。
如何在 pyside6.3.0
中导入 qtwidgets
模块?
编辑:
很明显,它正在导入Pyside6软件包,但它没有导入QTWIDGETS,QTGUI,QTCORE
#!/usr/bin/env python3.10
import sys
import PySide6
from PySide6 import QtWidgets
from PySide6.QtWidgets import (QApplication, QMainWindow, QWidget, QPushButton, QVBoxLayout, QHBoxLayout)
from PySide6 import QtCore
from PySide6.QtCore import (Qt, QSize)
if __name__ == "__main__":
app = QtWidgets.QApplication(sys.argv)
#TODO
app.exec()
输出等软件包:
$ ./test.py
Traceback (most recent call last):
File "./test.py", line 4, in <module>
from PySide6 import QtWidgets
ImportError: cannot import name 'QtWidgets' from 'PySide6' (~/.local/lib/python3.10/site-packages/PySide6/__init__.py)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
link @blackyy提供的链接帮助我解决了这个问题。
当我将
pyside6.2.4
升级为pyside6.3.0
使用时,就会发生 问题。 来自
pyside6
解决方案的模块:
必须清除
缓存
文件,然后重新安装pyside6
其他明智的方法它将使用以前的缓存文件和导入错误
使用继续来。the link provided by @Blackyy helped my resolve this issue.
The problem occurred when I upgraded
PySide6.2.4
toPySide6.3.0
usingSince we are upgrading the previous packages are left behind and will cause problem when we try to
import
modules frompyside6
Solution :
It is necessary to clear
cache
files before reinstallingpyside6
other wise it will use previous cache files and theimport error
using continue to come.尝试卸载pyside6 shiboken6 pyside6- essenitals pyside6-addons,然后重新安装pyside6
参见
Try uninstalling PySide6 shiboken6 PySide6-Essentials PySide6-Addons and then reinstall PySide6
See https://bugreports.qt.io/browse/PYSIDE-1891
无需
pip卸载
和pip Cache clear
No need to
pip uninstall
andpip cache clear
pyside6在pyside6.qtgui下移动课程。因此
来自pyside6.qtgui导入qdesktopservices
PySide6 move class under PySide6.QtGui. So
from PySide6.QtGui import QDesktopServices
来自pyside6.qtgui导入qstandarditem
解决了我的问题
from PySide6.QtGui import QStandardItem
solved my issue
“从pyside6.qtgui导入qAction”修复了问题。
它不是“来自pyside6.qtwidgets导入QACTION”。
"from PySide6.QtGui import QAction" fixed the issue.
Its not "from PySide6.QtWidgets import QAction".