this application failed to start because no qt platform plugin could be initialized reinstalling the

通过chat-GPT检索可以得到

这个错误通常是由于缺少Qt平台插件导致的。要解决这个问题,可以尝试以下方法:

1. 确保你已经正确安装了Qt平台插件。如果你使用的是conda或pip安装的Python,可以尝试重新安装PyQt或PySide。

2. 如果重新安装PyQt或PySide后仍然无法启动应用程序,你可以尝试在应用程序的顶部添加以下行:

```
import os
os.environ['QT_QPA_PLATFORM_PLUGIN_PATH'] = '/path/to/your/Qt/plugins/folder'
```

并将`/path/to/your/Qt/plugins/folder`替换为你自己系统中Qt插件文件夹的路径。

3. 如果以上两种方法都无效,可以尝试安装著名的Qt平台插件 Qt5VirtualkeyboardPlugin 进行修复。安装方式可参考官方文档 https://doc.qt.io/qt-5/qtvirtualkeyboard-installation.html。

希望这能帮到你解决问题。

本人配置是conda环境,但多次尝试conda install pyqt5都下载失败,尽管我配置了环境源,但依旧显示conda无法找到pyqt5, 因此,最后使用pip install pyqt5 成功。尝试了多次了卸载重新安装Pyqt5问题依旧没有解决,最开始以为问题是由于conda 和 pip 不兼容类似的原因,导致没搜索到。

尝试过的方法:

1. pip uninstall pyqt5,然后去下载pyqt5的安装包,手动安装。(失败)

2.网上检索,说可能是环境变量的问题,然后就配置了如下环境变量。(失败)

 最后解决的办法:

在codna 虚拟环境software(自定义)中,卸载pyqt5后重新安装

(software) C:\Users\Administrator>pip install pyqt5
Collecting pyqt5
  Using cached PyQt5-5.15.9-cp37-abi3-win_amd64.whl (6.8 MB)
Requirement already satisfied: PyQt5-sip<13,>=12.11 in c:\programdata\miniconda3\envs\software\lib\site-packages (from pyqt5) (12.12.0)
Requirement already satisfied: PyQt5-Qt5>=5.15.2 in c:\programdata\miniconda3\envs\software\lib\site-packages (from pyqt5) (5.15.2)
Installing collected packages: pyqt5
Successfully installed pyqt5-5.15.9

此时,安装完成,但运行依旧失败,所以再一次尝试重新下载,这时多了一个命令 pip install pyqt5-tools,这个是重点,可以从代码运行来看,在下载tools时,命令运行了Collecting pyqt5-plugins<5.15.9.3,>=5.15.9.2.2 (from PyQt5-tools)  Downloading 

而这正是我们所需要的插件

(software) C:\Users\Administrator>pip install PyQt5 -i https://pypi.douban.com/simple
Looking in indexes: https://pypi.douban.com/simple
Collecting PyQt5
  Downloading https://pypi.doubanio.com/packages/55/5d/8df8a2aa0de6588965d048fca9306cf15a5801be3078f195e8f8f41fa863/PyQt5-5.15.9-cp37-abi3-win_amd64.whl (6.8 MB)
     ---------------------------------------- 6.8/6.8 MB 3.9 MB/s eta 0:00:00
Requirement already satisfied: PyQt5-sip<13,>=12.11 in c:\programdata\miniconda3\envs\software\lib\site-packages (from PyQt5) (12.12.0)
Requirement already satisfied: PyQt5-Qt5>=5.15.2 in c:\programdata\miniconda3\envs\software\lib\site-packages (from PyQt5) (5.15.2)
Installing collected packages: PyQt5
Successfully installed PyQt5-5.15.9

(software) C:\Users\Administrator>pip install PyQt5-tools -i https://pypi.douban.com/simple
Looking in indexes: https://pypi.douban.com/simple
Collecting PyQt5-tools
  Downloading https://pypi.doubanio.com/packages/11/7e/3a5bce0e31650e091a16826d7a588be8bd56c2ac30871286b6c90d68ceeb/pyqt5_tools-5.15.9.3.3-py3-none-any.whl (29 kB)
Collecting click (from PyQt5-tools)
  Downloading https://pypi.doubanio.com/packages/c2/f1/df59e28c642d583f7dacffb1e0965d0e00b218e0186d7858ac5233dce840/click-8.1.3-py3-none-any.whl (96 kB)
     ---------------------------------------- 96.6/96.6 kB 1.8 MB/s eta 0:00:00
Requirement already satisfied: pyqt5==5.15.9 in c:\programdata\miniconda3\envs\software\lib\site-packages (from PyQt5-tools) (5.15.9)
Collecting pyqt5-plugins<5.15.9.3,>=5.15.9.2.2 (from PyQt5-tools)
  Downloading https://pypi.doubanio.com/packages/ca/35/a9bdf51500444ef9121e1b3c97746dc405c1033fbbe4293d4c84867220a6/pyqt5_plugins-5.15.9.2.3-cp38-cp38-win_amd64.whl (66 kB)
     ---------------------------------------- 66.8/66.8 kB ? eta 0:00:00
Collecting python-dotenv (from PyQt5-tools)
  Downloading https://pypi.doubanio.com/packages/44/2f/62ea1c8b593f4e093cc1a7768f0d46112107e790c3e478532329e434f00b/python_dotenv-1.0.0-py3-none-any.whl (19 kB)
Requirement already satisfied: PyQt5-sip<13,>=12.11 in c:\programdata\miniconda3\envs\software\lib\site-packages (from pyqt5==5.15.9->PyQt5-tools) (12.12.0)
Requirement already satisfied: PyQt5-Qt5>=5.15.2 in c:\programdata\miniconda3\envs\software\lib\site-packages (from pyqt5==5.15.9->PyQt5-tools) (5.15.2)
Collecting qt5-tools<5.15.2.2,>=5.15.2.1.2 (from pyqt5-plugins<5.15.9.3,>=5.15.9.2.2->PyQt5-tools)
  Downloading https://pypi.doubanio.com/packages/e2/45/3062d0df2bbc88ee4ea04b1073072b337b9e287c0b4ac12109729b413e2e/qt5_tools-5.15.2.1.3-py3-none-any.whl (13 kB)
Collecting colorama (from click->PyQt5-tools)
  Downloading https://pypi.doubanio.com/packages/d1/d6/3965ed04c63042e047cb6a3e6ed1a63a35087b6a609aa3a15ed8ac56c221/colorama-0.4.6-py2.py3-none-any.whl (25 kB)
Collecting qt5-applications<5.15.2.3,>=5.15.2.2.2 (from qt5-tools<5.15.2.2,>=5.15.2.1.2->pyqt5-plugins<5.15.9.3,>=5.15.9.2.2->PyQt5-tools)
  Downloading https://pypi.doubanio.com/packages/ae/a9/cd64cda6f58321c4a0021ced80117b225562efc42f1318ff2cea69c23eb7/qt5_applications-5.15.2.2.3-py3-none-win_amd64.whl (64.5 MB)
     ---------------------------------------- 64.5/64.5 MB 5.9 MB/s eta 0:00:00
Installing collected packages: qt5-applications, python-dotenv, colorama, click, qt5-tools, pyqt5-plugins, PyQt5-tools
Successfully installed PyQt5-tools-5.15.9.3.3 click-8.1.3 colorama-0.4.6 pyqt5-plugins-5.15.9.2.3 python-dotenv-1.0.0 qt5-applications-5.15.2.2.3 qt5-tools-5.15.2.1.3

但运行时依旧显示如下错误

 from PyQt5.QtWidgets import QApplication, QWidget, QLineEdit, QMessageBox, QMdiSubWindow 

ModuleNotFoundError: No module named 'PyQt5.sip'

 所以我得以,将pyqt5-sip与pyqt-qt5卸载重新安装。然后运行成功!!!!

总结:

pyqt5 下载有附加工具 pyqt5-tools需要同步下载;卸载重新包一定要卸载干净!

  • 8
    点赞
  • 37
    收藏
    觉得还不错? 一键收藏
  • 6
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 6
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值