没有名为 PyQt5.sip 的模块

发布于 2025-01-14 04:08:20 字数 304 浏览 1 评论 0原文

升级到 python-pyqt5 5.12-2 后,当我尝试从 QtWidgets 导入时收到此错误

from PyQt5.QtWidgets import * 

错误:

Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'PyQt5.sip'

知道如何解决此问题吗?

After upgrading to python-pyqt5 5.12-2 I get this error when I try to import from QtWidgets

from PyQt5.QtWidgets import * 

Error:

Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'PyQt5.sip'

Any idea on how can I solve this issue?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(6

终止放荡 2025-01-21 04:08:20

按照此处的建议 pyuic5 - ModuleNotFoundError: No module named PyQt5.sip

尝试卸载并重新安装所有 PyQt 相关库:

pip uninstall PyQt5
pip uninstall PyQt5-sip
pip uninstall PyQtWebEngine

然后安装再次使用它们,这将修复:

ModuleNotFoundError: No module named 'PyQt5.sip'
ModuleNotFoundError: No module named 'PyQt5.QtWebEngineWidgets'

PPS.:如果您在卸载库时遇到问题,请转到您的 Python 文件夹,例如C:\Users\\AppData\Local\Programs\Python\Python\Lib\site-packages 并手动删除 PyQt 文件夹,它们会卸载所有内容并再次安装(确保你有最新的 Python 版本并升级了你的 pip)

As suggested here pyuic5 - ModuleNotFoundError: No module named PyQt5.sip

Try uninstalling and re-installing all PyQt related libraries:

pip uninstall PyQt5
pip uninstall PyQt5-sip
pip uninstall PyQtWebEngine

Then install them again, this will fix:

ModuleNotFoundError: No module named 'PyQt5.sip'
ModuleNotFoundError: No module named 'PyQt5.QtWebEngineWidgets'

PPS.:If you got problems uninstalling the libraries, go to your Python folder, like C:\Users\<USERNAME>\AppData\Local\Programs\Python\Python<PYTHON-VERSION>\Lib\site-packages and manually delete the PyQt folders, them uninstall everything and install again (Make sure you have the latest Python version and upgraded your pip too)

枯寂 2025-01-21 04:08:20

原因是 PyQt-5.11 中的向后不兼容更改

geoptics中这个修复适用于旧版本和新版本:

try:
    # new location for sip
    # https://www.riverbankcomputing.com/static/Docs/PyQt5/incompatibilities.html#pyqt-v5-11
    from PyQt5 import sip
except ImportError:
    import sip

The reason is a backward incompatible change in PyQt-5.11

In geoptics this fix works on old and new versions:

try:
    # new location for sip
    # https://www.riverbankcomputing.com/static/Docs/PyQt5/incompatibilities.html#pyqt-v5-11
    from PyQt5 import sip
except ImportError:
    import sip
梓梦 2025-01-21 04:08:20

如果您使用 make 文件从源代码构建 sip 和 PyQt5,请务必检查 PyQt5 install

注意

构建 PyQt5 v5.11 或更高版本时,您必须配置 SIP 来创建
使用类似于以下命令的 sip 模块的私有副本
以下:

python configure.py --sip-module PyQt5.sip

如果您已经安装了 SIP 并且您只想构建并
安装模块的私有副本,然后添加 --no-tools 选项。

If you're building sip and PyQt5 from source using make files, make sure to check PyQt5 install docs. In particular,

Note

When building PyQt5 v5.11 or later you must configure SIP to create a
private copy of the sip module using a command line similar to the
following:

python configure.py --sip-module PyQt5.sip

If you already have SIP installed and you just want to build and
install the private copy of the module then add the --no-tools option.

南城追梦 2025-01-21 04:08:20

我修复了这个问题

升级pyqt5版本5.15.0时出现此问题

恢复到之前的版本就没有问题了。

我有
python -V: 3.7.4

PYQT5 5.14.1 和 PYSIDE 5.14.1 工作正常

I repaired this problem

This problem occurred when upgrading pyqt5 version 5.15.0

There was no problem when I reverted to the previous version.

I have
python -V: 3.7.4

PYQT5 5.14.1 and PYSIDE 5.14.1 works fine

惟欲睡 2025-01-21 04:08:20

您应该将 PyQt5.sip 添加到隐藏导入中;这应该可以解决问题。

You should add PyQt5.sip to hidden imports; that should solve the issue.

思念满溢 2025-01-21 04:08:20

除了塔德乌(https://stackoverflow.com/a/58880976/12455023)提供的答案外,我还想建议检查您的库的版本以确保它们匹配。

使用 pip show

这将帮助您确保早期安装不会与当前安装发生冲突。

使用PyQt5PyQt5-sipPyQtWebEngine代替library_name。如果系统中存在其中任何一个,请使用 pip uninstall== 删除该库。

一旦确保这些库不存在其他版本,您就可以重新安装该库的首选版本。

In addition to the answer provided by Tadeu (https://stackoverflow.com/a/58880976/12455023) I would also suggest checking version of your libraries to make sure that they match.

Use pip show <library_name>

This will help you to make sure that no earlier installation is conflicting with your current installation.

In place of library_name use PyQt5, PyQt5-sip, PyQtWebEngine. If any of them is present in the system, then use pip uninstall <library_name>==<version_number> to remove that library.

Once you made sure that no other versions of these libraries are there, then you can reinstall the preferred version of that library.

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