在看这篇文章的你,是不是有PyQt5 ImportError:DLL load failed的问题?
我曾经也有过。
>>> from PyQt5 import QtWidgets
Traceback (most recent call last):
File "", line 1, in
from PyQt5 import QtWidgets
ImportError:DLL load failed:the specified module could not be found.
曾经用了多少种办法都不行:
- 缺少python3.dll,下载即可
我去Python的库里看了看,明明有python3.dll啊!
- 重新下载PyQt5
我卸载再安装了一次PyQt5,但是依旧报错。
- 用conda下载PyQt5,或建立虚拟环境
我用conda install PyQt5试了试,结果不仅下载不成功,conda还报错了。。。
建立虚拟环境,问题依旧。
真是太令人抓狂了!我在网上翻来翻去,终于找到一个答案:
- 下载PyQt5 v.5.15.2
我试了试pip install PyQt5==5.15.2,尝试from PyQt5 import QtWidgets。
问题依旧。
等等!在版本5.15.2里,有三个奇奇怪怪的.pyi文件,其中就包括QtWidgets。
(改了之后的样子)
于是,我把它们改成.py文件,在重新导入了一下,问题完美解决~



