解决方案在分割线下面。前面是情况说明,如果一样就可以用下面的解决方案。
在打开spyder时anaconda给我来了个报错信息。。。
File "C:\MyWin\DevelopmentEnvironment\Anaconda3\Scripts\spyder-script.py", line 10, in
sys.exit(main())
File "C:\MyWin\DevelopmentEnvironment\Anaconda3\lib\site-packages\spyder\app\start.py", line 186, in main
from spyder.app import mainwindow
File "C:\MyWin\DevelopmentEnvironment\Anaconda3\lib\site-packages\spyder\app\mainwindow.py", line 90, in
from qtpy import QtWebEngineWidgets # analysis:ignore
File "C:\MyWin\DevelopmentEnvironment\Anaconda3\lib\site-packages\qtpy\QtWebEngineWidgets.py", line 22, in
from PyQt5.QtWebEngineWidgets import QWebEnginePage
ValueError: PyCapsule_GetPointer called with incorrect name
仔细看了一下后发现是PyQt5的问题,因为spyder和python内置的IDLE这些应用都是用PyQt来写的,所以对PyQt的版本其实是有要求的。
一般我们安装PyQt5和PyQt5-tools时会选择pip安装。但是pip安装会自动选择最新版本,并且会自动卸载掉之前的版本。这就会让一些用旧版本的应用打不开。但是这其实在安装的过程中pip会给我们提示的。像下面这个:
ERROR: pyqt5-tools 5.13.0.1.5 has requirement pyqt5==5.13.0, but you'll have pyqt5 5.12 which is incompatible.
但是大多数人都会在pip安装的过程中无视它。
好了现在来看看怎么办吧。
在cmd中输入:
pip check
这样就可以查看到用到PyQt的应用和包所需要的PyQt5版本了。
比如:
spyder 3.3.6 requires pyqtwebengine, which is not installed.
astroid 2.2.5 requires typed-ast, which is not installed.
xlwings 0.15.8 has requirement pywin32>=224, but you have pywin32 223.
spyder 3.3.6 has requirement pyqt5<5.13; python_version >= "3", but you have pyqt5 5.13.1.
pyqt5-tools 5.13.0.1.5 has requirement pyqt5==5.13.0, but you have pyqt5 5.13.1.
之后在pip中按需安装就行了。如:
pip install pyqt5==5.12.0