from PyQt5.QtWidgets import QApplication, QMessageBox
ImportError: DLL load failed while importing QtWidgets: 找不到指定的模块。
什么插件都装上了就是运行起来报错。
from PyQt5.QtWidgets import QApplication, QMessageBox
ImportError: DLL load failed while importing QtWidgets: 找不到指定的模块。
什么插件都装上了就是运行起来报错。
关注引自免费微信小程序:皆我百晓生
这个错误通常是因为缺少与PyQt5相关的动态链接库(.dll文件)或者这些文件没有正确地添加到系统的PATH环境变量中。为了解决这个问题,可以尝试以下几个步骤:
pip uninstall pyqt5
pip install pyqt5
Windows:
python -c "import sys; print(sys.path)"
Linux/Mac:
python3 -c "import sys; print(sys.path)"
手动添加缺失的DLL:
如果上述方法仍然无法解决,可能是某些特定的.dll文件缺失。你可以从网上找到相应的.dll文件并将其放到Python的Scripts目录下,或者将其添加到系统环境变量的PATH中。
使用Anaconda: 如果你使用的是Anaconda,可以创建一个新的环境并在这个环境中安装PyQt5,这样可以避免与其他程序冲突:
conda create -n new_env python=3.7
conda activate new_env
conda install pyqt
安装Visual C++ Redistributable: 有时这个错误是由于缺少Microsoft Visual C++ Redistributable导致的。你可以下载并安装对应版本的Visual C++ Redistributable:https://support.microsoft.com/en-us/topic/the-latest-supported-visual-c-downloads-2647da03-1eea-4433-9aff-95f26a218cc0
清理缓存: 有时候Python的缓存可能会导致问题,试着清除一下pip的缓存:
pip cache purge
如果以上方法都无法解决问题,那么可能是你的操作系统、Python版本或其他软件配置导致的兼容性问题。在这种情况下,可能需要更详细的系统信息才能提供更具体的解决方案。请尝试上述步骤,看看是否能解决问题。