pyuic5 - ModuleNotFoundError:没有名为 PyQt5.sip 的模块

2022-01-12 00:00:00 python pyqt5 anaconda

问题描述

我刚刚在我的 Windows 系统上安装了带有 Python 3.6 的 Anaconda 5.2.还通过具有管理员权限的 pip 安装了 pyqt5 和 pyqt5-tools.现在,当我运行 pyuic5.exe 来转换 ui 文件时,它显示以下错误:

I have just installed Anaconda 5.2 with Python 3.6 on my windows system. Also installed pyqt5 and pyqt5-tools via pip with administrator privilege. Now when I run pyuic5.exe for converting ui files it shows following error:

Traceback (most recent call last):
  File "C:UsersAshfaqurRahmanAnaconda3libunpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
  File "C:UsersAshfaqurRahmanAnaconda3libunpy.py", line 85, in _run_code
exec(code, run_globals)
  File "C:UsersAshfaqurRahmanAppDataRoamingPythonPython36site-packagesPyQt5uicpyuic.py", line 26, in <module>
from PyQt5 import QtCore
ModuleNotFoundError: No module named 'PyQt5.sip'

我尝试使用 pip 安装 PyQt5-sip 包.但是它已经安装在我的系统中了.

I have tried installing PyQt5-sip package using pip. Buts its already installed in my system.

为什么会出现这个问题?我该如何解决这个问题?

Why this problem is occurring? How can I solve this problem?


解决方案

根据Agile_Eagle的建议来自我刚刚卸载了 pyqt5pyqt5-tools 软件包并重新安装了它们的评论.问题解决了!

According to Agile_Eagle's suggestion from the comments I just uninstalled pyqt5 and pyqt5-tools packages and the reinstalled them. Problem solved!

PS.:如果您仍然遇到 PyQt 问题,请尝试卸载所有 PyQt 相关库:

PS.: If you still got problems with PyQt, try uninstalling all of the 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.:如果您在卸载库时遇到问题,请转到您的 Python 文件夹,例如 C:Users<USERNAME>AppDataLocalProgramsPythonPython<PYTHON-VERSION>Libsite-packages 并手动删除 PyQt 文件夹,然后卸载所有内容并重新安装(确保您拥有最新的 Python 版本并升级您的 pip)

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

相关文章