没有名为 PyQt5.sip 的模块
升级到 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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
按照此处的建议 pyuic5 - ModuleNotFoundError: No module named PyQt5.sip
尝试卸载并重新安装所有 PyQt 相关库:
然后安装再次使用它们,这将修复:
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:
Then install them again, this will fix:
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)原因是 PyQt-5.11 中的向后不兼容更改
在
geoptics
中这个修复适用于旧版本和新版本:The reason is a backward incompatible change in PyQt-5.11
In
geoptics
this fix works on old and new versions:如果您使用 make 文件从源代码构建 sip 和 PyQt5,请务必检查 PyQt5 install
If you're building sip and PyQt5 from source using make files, make sure to check PyQt5 install docs. In particular,
我修复了这个问题
升级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
您应该将 PyQt5.sip 添加到隐藏导入中;这应该可以解决问题。
You should add PyQt5.sip to hidden imports; that should solve the issue.
除了塔德乌(https://stackoverflow.com/a/58880976/12455023)提供的答案外,我还想建议检查您的库的版本以确保它们匹配。
使用
pip show
这将帮助您确保早期安装不会与当前安装发生冲突。
使用
PyQt5
、PyQt5-sip
、PyQtWebEngine
代替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 usepip 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.