升级Pyside6后,错误没有名为' pyside6.qtwidgets'

发布于 2025-01-22 09:46:00 字数 1375 浏览 1 评论 0 原文

升级到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)

After upgrading to PySide6.3.0 getting error ModuleNotFoundError: No module named 'PySide6.QtWidgets'

source

import sys
from PySide6.QtWidgets import QApplication, QLabel

app = QApplication(sys.argv)
label = QLabel("Hello World!")
label.show()
app.exec()

error:

$ 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'

Seems like there are changes in PySide6.3.0 .

How to import QtWidgets module in PySide6.3.0?

Edit:

It is clear it is importing PySide6 package but its not importing packages like 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()

output:

$ ./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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(6

游魂 2025-01-29 09:46:00

link @blackyy提供的链接帮助我解决了这个问题。

有问题的位是因为更新不做
“卸载/安装”并留下一些文件,并且不会覆盖
Pyside6目录带有新两个车轮的内容。如果你
检查您的网站包装,您只能剩下3个模块。

当我将 pyside6.2.4 升级为 pyside6.3.0 使用时

$ python3.10 -m pip install --upgrade pyside6

,就会发生 问题。 来自 pyside6 解决方案的模块

$ python3.10 -m pip uninstall pyside6 pyside6-addons pyside6-essentials shiboken6
$ python3.10 -m pip cache purge
$ python3.10 -m pip install pyside6

必须清除缓存文件,然后重新安装 pyside6 其他明智的方法它将使用以前的缓存文件和导入错误使用继续来。

the link provided by @Blackyy helped my resolve this issue.

The problematic bit is because the update doesn't do a
'uninstall/install' and leave some files around, and doesn't override
the PySide6 directory with the content of the new two wheels. If you
check your site-packages you will see only like 3 modules remained.

The problem occurred when I upgraded PySide6.2.4 to PySide6.3.0 using

$ python3.10 -m pip install --upgrade pyside6

Since we are upgrading the previous packages are left behind and will cause problem when we try to import modules from pyside6

Solution :

$ python3.10 -m pip uninstall pyside6 pyside6-addons pyside6-essentials shiboken6
$ python3.10 -m pip cache purge
$ python3.10 -m pip install pyside6

It is necessary to clear cache files before reinstalling pyside6 other wise it will use previous cache files and the import error using continue to come.

我要还你自由 2025-01-29 09:46:00

尝试卸载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

花想c 2025-01-29 09:46:00
$ python3.10 -m pip install --force-reinstall --no-cache-dir pyside6

无需 pip卸载 pip Cache clear

$ python3.10 -m pip install --force-reinstall --no-cache-dir pyside6

No need to pip uninstall and pip cache clear

十雾 2025-01-29 09:46:00

pyside6在pyside6.qtgui下移动课程。因此

来自pyside6.qtgui导入qdesktopservices

PySide6 move class under PySide6.QtGui. So

from PySide6.QtGui import QDesktopServices

对你的占有欲 2025-01-29 09:46:00

来自pyside6.qtgui导入qstandarditem

解决了我的问题

from PySide6.QtGui import QStandardItem

solved my issue

安穩 2025-01-29 09:46:00

“从pyside6.qtgui导入qAction”修复了问题。
它不是“来自pyside6.qtwidgets导入QACTION”。

"from PySide6.QtGui import QAction" fixed the issue.
Its not "from PySide6.QtWidgets import QAction".

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文