ermutuxia

2021-04-16   阅读量: 14135

Python

由于种种原因spyder突然用不了了,于是进行了如下的神操作 (待整理)

扫码加入数据分析学习群

由于种种原因spyder突然用不了了,于是进行了如下的神操作,发此贴记录我的悲催历程


看些有哪些spyder版本可以安装


(base) C:\Users\Administrator>pip install spyder==*

ERROR: Could not find a version that satisfies the requirement spyder==* (from v

ersions: 2.3.0, 2.3.1, 2.3.2, 2.3.3, 2.3.4, 2.3.5.2, 2.3.6, 2.3.7, 2.3.8, 2.3.9,

3.0.0b2, 3.0.0b3, 3.0.0b4, 3.0.0b5, 3.0.0b6, 3.0.0b7, 3.0.0, 3.0.1, 3.0.2, 3.1.

0, 3.1.1, 3.1.2, 3.1.3, 3.1.4, 3.2.0, 3.2.1, 3.2.2, 3.2.3, 3.2.4, 3.2.5, 3.2.6,

3.2.7, 3.2.8, 3.3.0, 3.3.1, 3.3.2, 3.3.3, 3.3.4, 3.3.5, 3.3.6, 4.0.0b1, 4.0.0b2,

4.0.0b3, 4.0.0b4, 4.0.0b5, 4.0.0b6, 4.0.0b7, 4.0.0rc1, 4.0.0rc2, 4.0.0rc3, 4.0.

0, 4.0.1, 4.1.0, 4.1.1, 4.1.2, 4.1.3, 4.1.4, 4.1.5, 4.1.6, 4.2.0, 4.2.1, 4.2.2,

4.2.3, 4.2.4, 4.2.5, 5.0.0a1, 5.0.0a2, 5.0.0a3, 5.0.0a4, 5.0.0a5, 5.0.0a6, 5.0.0

a7, 5.0.0)

ERROR: No matching distribution found for spyder==*



尝试安装spyder==4.1.6


pip install --use-feature=2020-resolver spyder==4.1.6 -i https://pypi.douban.com/simple


出现如下错误提示

ERROR: pyls-spyder 0.3.2 requires python-language-server>=0.36.2, but you'll hav

e python-language-server 0.34.1 which is incompatible.

distributed 2.30.1 requires cloudpickle>=1.5.0, but you'll have cloudpickle 1.3.

0 which is incompatible.



所以我们降低spyder的安装版本试试

pip install --use-feature=2020-resolver spyder==3.3.6 -i https://pypi.douban.com/simple



WARNING: Error parsing requirements for python-language-server: [Errno 2] No suc

h file or directory: 'd:\\programdata\\anaconda3\\lib\\site-packages\\python_lan

guage_server-0.35.1.dist-info\\METADATA'

虽然安装过程里面出现一些错误提示,但是最终还是说 Successfully uninstalled spyder-4.1.6

Successfully installed spyder-3.3.6 spyder-kernels-1.9.4 可以认为是安装成功了


然后我们输入spyder3执行,弹出一个对话框



Spyder crashed during last session. .

If Spyder does not start at all and before submitting a bug report,

please try to reset settings to defaults by running Spyder with the

command line option '--reset':spyder --reset

Wa rning: this command will remove all your Spyder configuration files

located in 'C:\Users\Administrator\.spyder-py3).


If Spyder still fails to launch, you should consult our comprehensive


Troubleshooting Guide, which when followed carefully solves the vast


majority of crashes; also, take the time to search for known bugs or


discussions matching your situation before submitting a report to our

issue tracker. Your feedback will always be greatly appreciated.

因为之前没有正确保存和退出程序,第二次打开出现如下这种情况:





我们点击ok关闭这个提示窗口

然后输入spyder3 --reset

没有弹出那个错误提示,但是也没有成功打开spyder



删除这个文件"C:\Users\Administrator\.spyder-py3"

然后再启动spyder


"C:\Users\Administrator\.matplotlib"

删掉这个文件,然后再启动spyder


然后输入spyder3 --reset 发现这个命令只是起到生成上面删除的那两个文件的作用


然后输入spyder3 回车后感觉spyder马上可以打开的样子,但是等了一会,那个出现的spyder打开界面又消失了。

还是无法启动spyder

执行pip check会有下面这个提示

(base) C:\Users\Administrator>pip check

WARNING: Error parsing requirements for spyder-kernels: [Errno 2] No such file o

r directory: 'd:\\programdata\\anaconda3\\lib\\site-packages\\spyder_kernels-1.9

.4.dist-info\\METADATA'

WARNING: Error parsing requirements for python-language-server: [Errno 2] No suc

h file or directory: 'd:\\programdata\\anaconda3\\lib\\site-packages\\python_lan

guage_server-0.35.1.dist-info\\METADATA'


我们去文件夹看了有spyder_kernels-1.9.4.dist-info但是里面确实没有METADATA文件夹


然后我们重新安装 spyder-kernels库

先把已有的spyder_kernels-1.9.4.dist-info spyder_kernels spyder_kernels-0.5.2.dist-info文件夹删掉

然后重装

pip install --use-feature=2020-resolver spyder-kernels==1.9.4 -i https://pypi.douban.com/simple

然后出现下面的错误提示

ERROR: spyder 3.3.6 requires spyder-kernels

kernels 1.9.4 which is incompatible.

Successfully installed spyder-kernels-1.9.4

然后我们先卸载装好的spyder-kernels-1.9.4,然后重新装指定版本

pip uninstall spyder-kernels 卸载成功了,文件夹也消失了

然后装和spyder相匹配的版本

pip install --use-feature=2020-resolver spyder-kernels==0.5.0 -i https://pypi.douban.com/simple


然后我们再升级spyder

pip install --use-feature=2020-resolver spyder==3.3.6 -i https://pypi.douban.com/simple


然后再pip check

(base) C:\Users\Administrator>pip check

WARNING: Error parsing requirements for python-language-server: [Errno 2] No suc

h file or directory: 'd:\\programdata\\anaconda3\\lib\\site-packages\\python_lan

guage_server-0.35.1.dist-info\\METADATA'

pyls-spyder 0.3.2 requires python-language-server, which is not installed.

pyls-black 0.4.6 requires python-language-server, which is not installed.

tensorflow 2.4.1 has requirement numpy~=1.19.2, but you have numpy 1.20.2.


看来python-language-server有问题,那我们就重装这个依赖库


删掉原有的两个文件夹python_language_server-0.34.1.dist-info python_language_server-0.35.1.dist-info

这两个文件是已经损坏的文件是怎么损坏的呢。有可能你在安装过程中突然中断或者其他什么原因,导致两个文件夹里的一些关键文


件丢掉了。

我们要手动删除这两个文件夹,然后再重新安装


pip install --use-feature=2020-resolver python_language_server==0.35.1 -i https://pypi.douban.com/simple

安装成功了,但是又版本不匹配的提示

ERROR: pyls-spyder 0.3.2 requires python-language-server>=0.36.2, but you'll hav

e python-language-server 0.35.1 which is incompatible.

Successfully installed python-language-server-0.35.1

我们卸载python_language_server==0.35.1然后重新装python-language-server>=0.36.2

pip install --use-feature=2020-resolver python_language_server==0.36.2 -i https://pypi.douban.com/simple


装python_language_server成功之后我们再运行

pip check

(base) C:\Users\Administrator>pip check

tensorflow 2.4.1 has requirement numpy~=1.19.2, but you have numpy 1.20.2.

发现没有关于spyder的版本错误提示了。


接下来更新spyder,没有发现错误提示

pip install spyder==3.3.6 update -i https://pypi.douban.com/simple



然后我们再启动spyder3 --reset试试

然后输入spyder3

还是过一会就关闭了,还是打不开

spyder setting up main window就失败了






需要注意的地方是我们在安装spyder库的时候需要安装一些依赖库,

如果已有的依赖库版本不对,那么在安装spyder库的过程中,他会卸载这些库,然后安装符合要求的版本库。

但是如果想要卸载的库已经损害(或者是只剩下写碎片),那你卸载就不能成功,因此也不能安装成功。

这是我们需要把手动剩余的碎片文件夹删掉,然后再安装spyder



通过前面的操作我们已经将那些损坏的文件删掉了并且下载了新的版本,如果再遇到需要卸载库的情况应该会自动卸载和安装。

接下来我们试一下安装spyder4.2.5试试


pip install spyder==4.2.5 update -i https://pypi.douban.com/simple --user



成功安装了spyder==4.2.5 也没有出现错误提示,但是spyder还是无法启动






有人说这是因为很多库没有更新导致的,因此执行下面的命令

conda upgrade --all


升级并没有完全升级成功


然后再启动spyder,仍然是过一会就退出了。


然后卸载spyder重装

pip uninstall


pip install spyder==4.2.5 update --use-feature=2020-resolver -i https://pypi.douban.com/simple --user


ERROR: -pyder 3.3.6 requires spyder-kernels


1.10.3


然后spyder3还是不能打开


然后重启电脑试试

结果还是不能打开spyder


用记事本方式打开下面这个文件

"D:\ProgramData\Anaconda3\Lib\site-packages\tornado\platform\asyncio.py"


卸载spyder之后在navigator里面安装spyder,结果提示

CondaHTTPError: HTTP 000 CONNECTION FAILED for url<https://repo.anaconda.com/pkgs/main/win-


64/repodata.json>
Elapsed: -

An HTTP error occurred when trying to retrieve this URL.
HTTP errors


are often intermittent, and a simple retry will get you on your way.

If your current network has


https://www.anaconda.com blocked, please file
a support request with your network engineering


team.

'https://repo.anaconda.com/pkgs/main/win-64'


这是什么意思?


这主要是anaconda延迟过高导致。

如何解决这个问题?

通过给.condarc文件添加国内镜像源的方式来解决延迟过高的问题。


执行下面的命令

conda config --add channels http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/win-64


这样就会把上面这个channel增加到.condarc文件里面


卸载spyder之后在navigator里面安装spyder,

在那个窗口下方的状态栏显示installing application spyder on D:\ProgramData\Anaconda3

说明spyder是一个应用。

然后我干了一会别的事,没看电脑,竟然显示安装好了,我看看能不能用

我在navigator spyder下面点击lanch,结果过会出现错误提示


Traceback (most recent call last):

File "D:\ProgramData\Anaconda3\lib\site-packages\astroid\astpeephole.py", line 17, in

_TYPES = (_ast.Str, _ast.Bytes)

AttributeError: module '_ast' has no attribute 'Str'


During handling of the above exception, another exception occurred:


Traceback (most recent call last):

File "D:\ProgramData\Anaconda3\Scripts\spyder-script.py", line 10, in

sys.exit(main())

File "D:\ProgramData\Anaconda3\lib\site-packages\spyder\app\start.py", line 205, in main

mainwindow.main()

File "D:\ProgramData\Anaconda3\lib\site-packages\spyder\app\mainwindow.py", line 3651, in main

mainwindow = run_spyder(app, options, args)

File "D:\ProgramData\Anaconda3\lib\site-packages\spyder\app\mainwindow.py", line 3526, in run_spyder

main.setup()

File "D:\ProgramData\Anaconda3\lib\site-packages\spyder\app\mainwindow.py", line 982, in setup

module = importlib.import_module(

File "D:\ProgramData\Anaconda3\lib\importlib\__init__.py", line 127, in import_module

return _bootstrap._gcd_import(name[level:], package, level)

File "", line 1014, in _gcd_import

File "", line 991, in _find_and_load

File "", line 975, in _find_and_load_unlocked

File "", line 671, in _load_unlocked

File "", line 783, in exec_module

File "", line 219, in _call_with_frames_removed

File "D:\ProgramData\Anaconda3\lib\site-packages\spyder\plugins\pylint\__init__.py", line 14, in

from .plugin import Pylint as PLUGIN_CLASS

File "D:\ProgramData\Anaconda3\lib\site-packages\spyder\plugins\pylint\plugin.py", line 29, in

from spyder.plugins.pylint.confpage import (PylintConfigPage,

File "D:\ProgramData\Anaconda3\lib\site-packages\spyder\plugins\pylint\confpage.py", line 16, in

from spyder.plugins.pylint.widgets.pylintgui import PylintWidget

File "D:\ProgramData\Anaconda3\lib\site-packages\spyder\plugins\pylint\widgets\pylintgui.py", line 37, in

from spyder.plugins.pylint.utils import get_pylintrc_path

File "D:\ProgramData\Anaconda3\lib\site-packages\spyder\plugins\pylint\utils.py", line 16, in

import pylint.config

File "D:\ProgramData\Anaconda3\lib\site-packages\pylint\config\__init__.py", line 38, in

from pylint.config.configuration_mixin import ConfigurationMixIn

File "D:\ProgramData\Anaconda3\lib\site-packages\pylint\config\configuration_mixin.py", line 4, in

from pylint.config.option_manager_mixin import OptionsManagerMixIn

File "D:\ProgramData\Anaconda3\lib\site-packages\pylint\config\option_manager_mixin.py", line 16, in

from pylint import utils

File "D:\ProgramData\Anaconda3\lib\site-packages\pylint\utils\__init__.py", line 45, in

from pylint.utils.ast_walker import ASTWalker

File "D:\ProgramData\Anaconda3\lib\site-packages\pylint\utils\ast_walker.py", line 6, in

from astroid import nodes

File "D:\ProgramData\Anaconda3\lib\site-packages\astroid\__init__.py", line 67, in

from astroid.builder import parse, extract_node

File "D:\ProgramData\Anaconda3\lib\site-packages\astroid\builder.py", line 26, in

from astroid import rebuilder

File "D:\ProgramData\Anaconda3\lib\site-packages\astroid\rebuilder.py", line 17, in

from astroid import astpeephole

File "D:\ProgramData\Anaconda3\lib\site-packages\astroid\astpeephole.py", line 19, in

_TYPES = (_ast.Str, )

AttributeError: module '_ast' has no attribute 'Str'


然后我们再把安装的spyder卸载了

用pip uninstall spyder

完成之后在navigator spyder下面还可以看到lanch,当然我们点进去肯定是不行的,我们右键点击选择remove application

感觉这个过程非常慢,现在是8:30我看几点完成,8:36完成了。spyder下面又变成了install字样


我们在.condarc文件里再添加一个镜像源

conda config --add channels http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/win-64

把show_channel_urls参数值设定为yes

conda config --set show_channel_urls yes

在.condarc文件里把下面这一行手动删掉

- defaults

然后.condarc文件就变成了如下内容

channels:

- http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/win-64

- http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/win-64

- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free

ssl_verify: true

show_channel_urls: true


然后在cmd窗口执行

conda update --all #修改镜像源文件之后的升级速度明显变快了。很快就完成了。


我们把这个文件夹删掉 "C:\Users\Administrator\.spyder-py3"

然后重新安装spyder

conda install spyder


C:\Users\Administrator>conda install spyder

Collecting package metadata (current_repodata.json): done

Solving environment: failed with initial frozen solve. Retrying with flexible so

lve.

Solving environment: failed with repodata from current_repodata.json, will retry

with next repodata source.

Collecting package metadata (repodata.json): done

Solving environment: \

Warning: 2 possible package resolutions (only showing differing packages):

- http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/noarch::sphinx-3.5.3-

pyhd3eb1b0_0, http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/win-64::doc

utils-0.17-py38haa95532_1

- http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/noarch::sphinx-3.5.4-

pyhd3eb1b0_0, http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/win-64::doc

utils-0.16-py38done


## Package Plan ##


environment location: D:\ProgramData\Anaconda3


added / updated specs:

- spyder



The following packages will be downloaded:

The following packages will be DOWNGRADED:


parso 0.8.2-pyhd3eb1b0_0 --> 0.7.0-py_0



Proceed ([y]/n)?


不知道上面说的那些Solving environment warning是否会安装产生严重影响

我们根据提示输入y继续

接下来很快就安装完成了

然后我们启动spyder3试试,输入spyder3说不能识别,因此我们输入spyder,结果还是有下面的错误提示


C:\Users\Administrator>spyder

No QCoreApplication instance found. Application patches not applied. You have to

call load_stylesheet function after instantiation of QApplication to take effec

t.

Traceback (most recent call last):

File "D:\ProgramData\Anaconda3\lib\site-packages\spyder\app\mainwindow.py", li

ne 2146, in create_window

main.setup()

File "D:\ProgramData\Anaconda3\lib\site-packages\spyder\app\mainwindow.py", li

ne 737, in setup

from spyder.plugins.help.utils.sphinxify import CSS_PATH, DARK_CSS_PATH

File "D:\ProgramData\Anaconda3\lib\site-packages\spyder\plugins\help\__init__.

py", line 14, in

from spyder.plugins.help.plugin import Help

File "D:\ProgramData\Anaconda3\lib\site-packages\spyder\plugins\help\plugin.py

", line 23, in

from spyder.plugins.console.api import ConsoleActions

File "D:\ProgramData\Anaconda3\lib\site-packages\spyder\plugins\console\__init

__.py", line 17, in

from spyder.plugins.console.plugin import Console

File "D:\ProgramData\Anaconda3\lib\site-packages\spyder\plugins\console\plugin

.py", line 22, in

from spyder.plugins.application.plugin import ApplicationActions

File "D:\ProgramData\Anaconda3\lib\site-packages\spyder\plugins\application\__

init__.py", line 14, in

from spyder.plugins.application.plugin import Application

File "D:\ProgramData\Anaconda3\lib\site-packages\spyder\plugins\application\pl

ugin.py", line 26, in

from spyder.plugins.application.container import (

File "D:\ProgramData\Anaconda3\lib\site-packages\spyder\plugins\application\co

ntainer.py", line 37, in

from spyder.utils.environ import WinUserEnvDialog

File "D:\ProgramData\Anaconda3\lib\site-packages\spyder\utils\environ.py", lin

e 19, in

from spyder.widgets.collectionseditor import CollectionsEditor

File "D:\ProgramData\Anaconda3\lib\site-packages\spyder\widgets\collectionsedi

tor.py", line 39, in

from spyder_kernels.utils.nsview import (

ImportError: cannot import name 'get_numpy_type_string' from 'spyder_kernels.uti

ls.nsview' (C:\Users\Administrator\AppData\Roaming\Python\Python38\site-packages

\spyder_kernels\utils\nsview.py)


During handling of the above exception, another exception occurred:


Traceback (most recent call last):

File "D:\ProgramData\Anaconda3\Scripts\spyder-script.py", line 10, in


sys.exit(main())

File "D:\ProgramData\Anaconda3\lib\site-packages\spyder\app\start.py", line 21

4, in main

mainwindow.main(options, args)

File "D:\ProgramData\Anaconda3\lib\site-packages\spyder\app\mainwindow.py", li

ne 2293, in main

mainwindow = create_window(app, splash, options, args)

File "D:\ProgramData\Anaconda3\lib\site-packages\spyder\app\mainwindow.py", li

ne 2148, in create_window

if main.console is not None:

File "D:\ProgramData\Anaconda3\lib\site-packages\spyder\app\mainwindow.py", li

ne 1159, in __getattr__

return self.get_plugin(self._INTERNAL_PLUGINS_MAPPING[attr])

File "D:\ProgramData\Anaconda3\lib\site-packages\spyder\app\mainwindow.py", li

ne 168, in get_plugin

raise SpyderAPIError('Plugin "{}" not found!'.format(plugin_name))

spyder.api.exceptions.SpyderAPIError: Plugin "internal_console" not found!


C:\Users\Administrator>



然后再navigator 里面启动spyder试试(如果在spyder下面看不到lanch,可以refresh一下就可以看到了),提示如下错误,和上


面的错误提示是完全一样的。

No QCoreApplication instance found. Application patches not applied. You have to call load_stylesheet function


after instantiation of QApplication to take effect.

Traceback (most recent call last):

File "D:\ProgramData\Anaconda3\lib\site-packages\spyder\app\mainwindow.py", line 2146, in create_window

main.setup()

File "D:\ProgramData\Anaconda3\lib\site-packages\spyder\app\mainwindow.py", line 737, in setup

from spyder.plugins.help.utils.sphinxify import CSS_PATH, DARK_CSS_PATH

File "D:\ProgramData\Anaconda3\lib\site-packages\spyder\plugins\help\__init__.py", line 14, in

from spyder.plugins.help.plugin import Help

File "D:\ProgramData\Anaconda3\lib\site-packages\spyder\plugins\help\plugin.py", line 23, in

from spyder.plugins.console.api import ConsoleActions

File "D:\ProgramData\Anaconda3\lib\site-packages\spyder\plugins\console\__init__.py", line 17, in

from spyder.plugins.console.plugin import Console

File "D:\ProgramData\Anaconda3\lib\site-packages\spyder\plugins\console\plugin.py", line 22, in

from spyder.plugins.application.plugin import ApplicationActions

File "D:\ProgramData\Anaconda3\lib\site-packages\spyder\plugins\application\__init__.py", line 14, in

from spyder.plugins.application.plugin import Application

File "D:\ProgramData\Anaconda3\lib\site-packages\spyder\plugins\application\plugin.py", line 26, in

from spyder.plugins.application.container import (

File "D:\ProgramData\Anaconda3\lib\site-packages\spyder\plugins\application\container.py", line 37, in

from spyder.utils.environ import WinUserEnvDialog

File "D:\ProgramData\Anaconda3\lib\site-packages\spyder\utils\environ.py", line 19, in

from spyder.widgets.collectionseditor import CollectionsEditor

File "D:\ProgramData\Anaconda3\lib\site-packages\spyder\widgets\collectionseditor.py", line 39, in

from spyder_kernels.utils.nsview import (

ImportError: cannot import name 'get_numpy_type_string' from 'spyder_kernels.utils.nsview' (C:\Users


\Administrator\AppData\Roaming\Python\Python38\site-packages\spyder_kernels\utils\nsview.py)


During handling of the above exception, another exception occurred:


Traceback (most recent call last):

File "D:\ProgramData\Anaconda3\Scripts\spyder-script.py", line 10, in

sys.exit(main())

File "D:\ProgramData\Anaconda3\lib\site-packages\spyder\app\start.py", line 214, in main

mainwindow.main(options, args)

File "D:\ProgramData\Anaconda3\lib\site-packages\spyder\app\mainwindow.py", line 2293, in main

mainwindow = create_window(app, splash, options, args)

File "D:\ProgramData\Anaconda3\lib\site-packages\spyder\app\mainwindow.py", line 2148, in create_window

if main.console is not None:

File "D:\ProgramData\Anaconda3\lib\site-packages\spyder\app\mainwindow.py", line 1159, in __getattr__

return self.get_plugin(self._INTERNAL_PLUGINS_MAPPING[attr])

File "D:\ProgramData\Anaconda3\lib\site-packages\spyder\app\mainwindow.py", line 168, in get_plugin

raise SpyderAPIError('Plugin "{}" not found!'.format(plugin_name))

spyder.api.exceptions.SpyderAPIError: Plugin "internal_console" not found!


然后执行pip check

C:\Users\Administrator>pip check

tensorflow 2.4.1 requires h5py, which is not installed.

tensorboard 2.4.1 requires werkzeug, which is not installed.

scikit-learn 0.24.1 requires threadpoolctl, which is not installed.

lesscpy 0.14.0 requires ply, which is not installed.

keras 2.4.3 requires h5py, which is not installed.

jupyterthemes 0.20.0 requires matplotlib, which is not installed.

jupyter-contrib-nbextensions 0.5.1 requires lxml, which is not installed.

-pyder 3.3.6 has requirement spyder-kernels

nels 1.10.3.

tensorflow 2.4.1 has requirement numpy~=1.19.2, but you have numpy 1.20.2.

spyder 5.0.0 has requirement qdarkstyle==3.0.2, but you have qdarkstyle 2.8.1.

spyder 5.0.0 has requirement spyder-kernels

ernels 1.10.3.

flake8 3.9.0 has requirement pycodestyle

2.6.0.

flake8 3.9.0 has requirement pyflakes

.

autopep8 1.5.6 has requirement pycodestyle>=2.7.0, but you have pycodestyle 2.6.

0.


C:\Users\Administrator>



那我们的spyder不能启动是不是因为qdarkstyle和spyder-kernels的版本不匹配导致的呢,

因为用conda update --all命令之后,spyder-kernels变成了1.10.3.

我们安装一下符合要求的版本

pip install qdarkstyle==3.0.2 update --use-feature=2020-resolver -i https://pypi.douban.com/simple --user

pip install spyder-kernels==2.0.1 update --use-feature=2020-resolver -i https://pypi.douban.com/simple --user


ERROR: pip's dependency resolver does not currently take into account all the pa

ckages that are installed. This behaviour is the source of the following depende

ncy conflicts.

-pyder 3.3.6 requires spyder-kernels

0.1 which is incompatible.

spyder 5.0.0 requires qdarkstyle==3.0.2, but you have qdarkstyle 2.8.1 which is

incompatible.

Successfully installed spyder-kernels-2.0.1


然后pip check 然后就不会有qdarkstyle版本不对的提示了。

然后再执行spyder

还是这个错误提示

(base) C:\Users\Administrator>spyder

No QCoreApplication instance found. Application patches not applied. You have to

call load_stylesheet function after instantiation of QApplication to take effec

t.



我们查看spyder对应的内核是什么还是出现上面的错误提示

(base) C:\Users\Administrator>spyder kernelspec list

No QCoreApplication instance found. Application patches not applied. You have to

call load_stylesheet function after instantiation of QApplication to take effec

t.

Traceback (most recent call last):

File "D:\ProgramData\Anaconda3\Scripts\spyder-script.py", line 10, in


sys.exit(main())

File "D:\ProgramData\Anaconda3\lib\site-packages\spyder\app\start.py", line 21

4, in main

mainwindow.main(options, args)


kernel_client.hb_channel.time_to_dead = 25.0

File "D:\ProgramData\Anaconda3\Scripts\jupyter_client\client.py", line 364, in

hb_channel

self._hb_channel = self.hb_channel_class(self.context, self.session, url)

File "D:\ProgramData\Anaconda3\lib\site-packages\qtconsole\util.py", line 64,

in __new__

QClass.__init__(inst)

TypeError: __init__() missing 1 required positional argument: 'context'


是不是说明spyder没有内核可用。jupyter 内核用的是如下

(base) C:\Users\Administrator>jupyter kernelspec list

Available kernels:

python3 D:\ProgramData\Anaconda3\share\jupyter\kernels\python3



在anaconda prompt窗口中我们用pip命令,把spyder卸载,然后用conda命令进行安装,没有错误提示,

(base) C:\Users\Administrator>conda install spyder

Collecting package metadata (current_repodata.json): done

Solving environment: done


# All requested packages already installed.


但是输入spyder和spyder3都没有反应

说 不是内部或外部命令,也不是可运行的程序或批处理文件。

conda list显示spyder版本是3.3.6 spyder-kernels版本是 1.10.3

pip list 看不到spyder ,而spyder-kernels版本是 2.0.1


conda install把spyder装到哪里去了呢?找了半天没有找到,那我们把conda install安装的spyder用conda uninstall spder卸


载掉试试

结果发现卸载不了

(base) C:\Users\Administrator>conda uninstall spyder

Collecting package metadata (repodata.json): done

Solving environment: failed


PackagesNotFoundError: The following packages are missing from the target enviro

nment:

- spyder

我们换conda remove命令试试发现跟前面的提示一模一样。

是不是就是因为以前的spyder没有卸载成功才导致这样的问题呢?如何把spyder彻底卸载呢

我们发现这个路径下有一个spyder文件夹,我们把这个文件夹手动删掉,然后再执行conda list看里面还有没有spyder

"D:\ProgramData\Anaconda3\Lib\site-packages\spyder"

结果conda list里面还是有spyder3.3.6



我们尝试把spyder-kernels 1.10.3删掉

conda uninstall spyder-kernels

我们看下执行结果 结果conda list下面还是有spyder-kernels 1.10.3

pip list下面spyder-kernels 的版本也变成 1.10.3


"D:\ProgramData\Anaconda3\Lib\site-packages\spyder_kernels-1.10.3.dist-info"这个文件夹下面只剩下spyder_kernels-


1.10.3.dist-info,没有2.0.1那个版本了。

我们再用conda 命令卸载spyder_kernels-1.10.3试试


(base) C:\Users\Administrator>conda uninstall spyder_kernels

Collecting package metadata (repodata.json): done

Solving environment: failed


PackagesNotFoundError: The following packages are missing from the target enviro

nment:

- spyder_kernels


我们再用pip 命令卸载spyder_kernels-1.10.3试试,结果提示卸载成功。

我们再用conda list命令看下spyder_kernels库是否还存在,发现spyder_kernels已经不存在了

我们再用pip list命令看下spyder_kernels库是否还存在,发现spyder_kernels也已经不存在了

现在的问题就是cond list下面显示有spyder库,但是又不知道这个库,或者是一些碎片文件放到哪了,想用也用不了。

我们再anaconda prompt里面用pip uninstall spyder 提示这个库不存在

我们再anaconda prompt里面用conda uninstall spyder 提示PackagesNotFoundError: The following packages are missing


from the target enviro

nment:

是不是因为在anaconda prompt里面不能执行呢?我们新打开一个cmd窗口输入conda uninstall spyder发现和在anaconda prompt


执行是一样提示

C:\Users\Administrator>conda uninstall spyder

Collecting package metadata (repodata.json): done

Solving environment: failed


PackagesNotFoundError: The following packages are missing from the target environment:

- spyder

我们把用户路径下的.spyder文件删除,然后再看conda list还是有spyder

C:\Users\Administrator>conda update spyder 执行这个命令想升级一下spyder,结果说spyder不存在,既然不存在那为什么在


condalist下面有呢?


我们重启下电脑试一下:仍然不能识别spyder或者spyder3


这样一直无穷无尽耽误时间太多,还是决定把安装的anaconda卸了重装,反正我是这么干的,强迫症患者,这样干净


用360将anaconda卸载了。卸载完成之后又手动把开始里面的快捷方式删掉了,还把appdata里面的一些关于anaconda conda的文件全部删掉了


卸载完成之后按照下面的链接安装anaconda

https://www.cda.cn/discuss/post/details/5f2a8378922c1e31e648de0f


可以使用spyder了就只能这样简单粗暴的解决问题了。没办法。

然后我还是执行下conda list 看看那个神奇的spyder3.3.6是否没有了

spyder 4.0.1 py37_0 defaults

spyder-kernels 1.8.1 py37_0 defaults


果然现在spyder已经变了,那个神奇的无法卸载无法删除无法更新无法使用也找不的spyder3.3.6 终于消失了,松了一口气



C:\Users\Administrator>conda

usage: conda-script.py [-h] [-V] command ...


conda is a tool for managing and deploying applications, environments and packag

es.


Options:


positional arguments:

command

clean Remove unused packages and caches.

compare Compare packages between conda environments.

config Modify configuration values in .condarc. This is modeled

after the git config command. Writes to the user .condarc

file (C:\Users\Administrator\.condarc) by default.

create Create a new conda environment from a list of specified

packages.

help Displays a list of available conda commands and their help

strings.

info Display information about current conda install.

init Initialize conda for shell interaction. [Experimental]

install Installs a list of packages into a specified conda

environment.

list List linked packages in a conda environment.

package Low-level conda package utility. (EXPERIMENTAL)

remove Remove a list of packages from a specified conda environment.

uninstall Alias for conda remove.

run Run an executable in a conda environment. [Experimental]

search Search for packages and display associated information. The

input is a MatchSpec, a query language for conda packages.

See examples below.

update Updates conda packages to the latest compatible version.

upgrade Alias for conda update.


optional arguments:

-h, --help Show this help message and exit.

-V, --version Show the conda version number and exit.


conda commands available from other packages:

build

convert

debug

develop

env

index

inspect

metapackage

render

server

skeleton

verify


C:\Users\Administrator>






.condarc删了怎么找回?


今天爱分享给大家带来condarc文件找不到的问题【解决办法】,希望能够帮助到大家。


在创建conda环境的时候,需要修改


condarc文件的内容。一开始怎么也找不到.condarc文件,系统提示也是无法找到该文件。通过查找资源,发现原来.condarc默认是


不会自动创建的,只有当用户第一次使用conda config命令时,系统才会自动创建.condarc文件。(有一个专用词,.condarc叫运行


期配置文件)


配置.

condarc文件


配置conda主要有两种语法,

一种是添加,一种是设置



conda config --add [options] [parameters]



conda config --set [options] [yes|no]



添加通道(默认已经包含defaults)



conda config --add channels defaults (会报错显示已经含有defaults)



添加清华镜像的国内通道



conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free



conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main



conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/r



添加环境目录envs_dirs



conda config --add envs_dirs [path] (example: /anaconda/envs)



添加pkgs_dirs



conda config --add pkgs_dirs [path] (example: /anaconda/envs)



设置ssl_verify



conda config --set ssl_verify yes



设置show_channel_urls



conda config --set show_channel_urls yes





我们在cmd窗口第一次执行conda config命令

结果在这个路径下生成了"C:\Users\Administrator\.condarc"

用记事本打开这个文件,发现里面的内容如下:

channels:

- defaults

ssl_verify: true

我们用conda config命令在里面添加一些国内的镜像源,比如在cmd命令窗口输入(先把那个.condarc文件关闭再执行)


conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free



执行完成没有错误提示,我们在打开.condarc文件看下有没有变化

channels:

- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free

- defaults

ssl_verify: true

在channels那里除了原有的defaults,还增加了我们刚刚通过cmd窗口命令添加的那个channel。







添加CDA认证专家【维克多阿涛】,微信号:【cdashijiazhuang】,提供数据分析指导及CDA考试秘籍。已助千人通过CDA数字化人才认证。欢迎交流,共同成长!
1.3457 1 1 关注作者 收藏

评论(1)

啊啊啊啊啊吖
2021-04-17

0.0000 0 0 回复

推荐课程