开发环境
- Anaconda3 + Pycharm
- Python3.7
报错描述
我是用的Pycharm+conda的环境进行开发的,有的时候会用到Spyder。
在我安装PyQt5后,使用Pycharm进行GUI的开发后发现,Anaconda中的Spyder打不开了:
并有了以下报错:
Traceback (most recent call last):
File "D:\Anaconda\installanaconda\Scripts\spyder-script.py", line 10, in
sys.exit(main())
File "D:\Anaconda\installanaconda\lib\site-packages\spyder\app\start.py", line 186, in main
from spyder.app import mainwindow
File "D:\Anaconda\installanaconda\lib\site-packages\spyder\app\mainwindow.py", line 90, in
from qtpy import QtWebEngineWidgets # analysis:ignore
File "D:\Anaconda\installanaconda\lib\site-packages\qtpy\QtWebEngineWidgets.py", line 22, in
from PyQt5.QtWebEngineWidgets import QWebEnginePage
ValueError: PyCapsule_GetPointer called with incorrect name
这个问题原来遇到过,由于没有使用Spyder的需求就一直没有想去解决。这是用于安装的PyQt5与spyder中带有的pyqt版本发生了冲突。于是我最终在stackoverflow上找到了解决方案
解决方案
原文是这样说的:
The solution is to downgrade PyQt5
.
pip install PyQt5==5.10.1
Collecting PyQt5==5.10.1
Downloading https://files.pythonhosted.org/packages/a7/22/67cc2bac6ae2cd3a7eabb2a2e91638b94bdc6e0503747e49670ce44bb5b0/PyQt5-5.10.1-5.10.1-cp35.cp36.cp37.cp38-none-win_amd64.whl (81.0MB)
100% |████████████████████████████████| 81.0MB 187kB/s
Requirement already satisfied: sip<4.20,>=4.19.4 in c:\anaconda3\lib\site-packages (from PyQt5==5.10.1) (4.19.8)
spyder 3.3.4 requires pyqtwebengine<5.13, which is not installed.
Installing collected packages: PyQt5
Found existing installation: PyQt5 5.12.1
Uninstalling PyQt5-5.12.1:
Successfully uninstalled PyQt5-5.12.1
Successfully installed PyQt5-5.10.1
This problem occurs because the PyQt5
I installed is beyond version as the version of spyder
.
所以,我将原先的PyQt5进行卸载后,安装了5.10.1版本的PyQt5。
之后对结果进行测试。
结果
先是看一下Spyder是否正常打开以及运行:
Spyder可以正常打开并且使用了。
然后检查PyQt模块是否能正常使用:
完事!