概述
最近多次安装卸载Anaconda2和Anaconda3,导致重新安装时老是出现两个问题,其中一个问题是Anaconda装完后,打开Anaconda Navigator报错,无法启动;令一个问题是Jupyter Notebook打开后显示kernel dead,防止以后再次遇到手足无措,在此写下解决方法。
1.Navigator Error:An unexpected error occurred on Navigator start-up
报错信息如下:
Main Error
could not determine a constructor for the tag 'tag:yaml.org,2002:python/unicode'
in "C:UsersZheng ChenAppDataLocalContinuumIObinstarconfig.yaml", line 1, column 1
Traceback
Traceback (most recent call last):
File "C:ProgramDataAnaconda2libsite-packagesanaconda_navigatorexceptions.py", line 75, in exception_handler
return_value = func(*args, **kwargs)
File "C:ProgramDataAnaconda2libsite-packagesanaconda_navigatorappstart.py", line 138, in start_app
window = run_app(splash)
File "C:ProgramDataAnaconda2libsite-packagesanaconda_navigatorappstart.py", line 64, in run_app
window = MainWindow(splash=splash, tab_project=False)
File "C:ProgramDataAnaconda2libsite-packagesanaconda_navigatorwidgetsmain_window.py", line 163, in __init__
self.api = AnacondaAPI()
File "C:ProgramDataAnaconda2libsite-packagesanaconda_navigatorapianaconda_api.py", line 2127, in AnacondaAPI
ANACONDA_API = _AnacondaAPI()
File "C:ProgramDataAnaconda2libsite-packagesanaconda_navigatorapianaconda_api.py", line 90, in __init__
self._client_api = ClientAPI()
File "C:ProgramDataAnaconda2libsite-packagesanaconda_navigatorapiclient_api.py", line 638, in ClientAPI
CLIENT_API = _ClientAPI()
File "C:ProgramDataAnaconda2libsite-packagesanaconda_navigatorapiclient_api.py", line 93, in __init__
self.reload_binstar_client()
File "C:ProgramDataAnaconda2libsite-packagesanaconda_navigatorapiclient_api.py", line 305, in reload_binstar_client
config = binstar_client.utils.get_config()
File "C:ProgramDataAnaconda2libsite-packagesbinstar_clientutilsconfig.py", line 229, in get_config
file_configs = load_file_configs(SEARCH_PATH)
File "C:ProgramDataAnaconda2libsite-packagesbinstar_clientutilsconfig.py", line 223, in load_file_configs
raw_data = collections.OrderedDict(kv for kv in itertools.chain.from_iterable(load_paths))
File "C:ProgramDataAnaconda2libcollections.py", line 69, in __init__
self.__update(*args, **kwds)
File "C:ProgramDataAnaconda2lib_abcoll.py", line 571, in update
for key, value in other:
File "C:ProgramDataAnaconda2libsite-packagesbinstar_clientutilsconfig.py", line 223, in
raw_data = collections.OrderedDict(kv for kv in itertools.chain.from_iterable(load_paths))
File "C:ProgramDataAnaconda2libsite-packagesbinstar_clientutilsconfig.py", line 203, in _dir_yaml_loader
yield filepath, load_config(filepath)
File "C:ProgramDataAnaconda2libsite-packagesbinstar_clientutilsconfig.py", line 187, in load_config
data = yaml_load(fd)
File "C:ProgramDataAnaconda2libsite-packagesbinstar_clientutilsyaml.py", line 9, in yaml_load
return safe_load(stream)
File "C:ProgramDataAnaconda2libsite-packagesyaml__init__.py", line 93, in safe_load
return load(stream, SafeLoader)
File "C:ProgramDataAnaconda2libsite-packagesyaml__init__.py", line 71, in load
return loader.get_single_data()
File "C:ProgramDataAnaconda2libsite-packagesyamlconstructor.py", line 39, in get_single_data
return self.construct_document(node)
File "C:ProgramDataAnaconda2libsite-packagesyamlconstructor.py", line 48, in construct_document
for dummy in generator:
File "C:ProgramDataAnaconda2libsite-packagesyamlconstructor.py", line 398, in construct_yaml_map
value = self.construct_mapping(node)
File "C:ProgramDataAnaconda2libsite-packagesyamlconstructor.py", line 208, in construct_mapping
return BaseConstructor.construct_mapping(self, node, deep=deep)
File "C:ProgramDataAnaconda2libsite-packagesyamlconstructor.py", line 127, in construct_mapping
key = self.construct_object(key_node, deep=deep)
File "C:ProgramDataAnaconda2libsite-packagesyamlconstructor.py", line 88, in construct_object
data = constructor(self, node)
File "C:ProgramDataAnaconda2libsite-packagesyamlconstructor.py", line 414, in construct_undefined
node.start_mark)
ConstructorError: could not determine a constructor for the tag 'tag:yaml.org,2002:python/unicode'
in "C:UsersZheng ChenAppDataLocalContinuumIObinstarconfig.yaml", line 1, column 1
解决方法:
windows下以管理员身份打开Anaconda Prompt,然后逐个输入下面的语句,进行更新(linux或Max下直接在终端输入即可)
conda update conda
conda update anaconda-navigator
conda update navigator-updater
若还是不行,再输入以下语句:
conda install anaconda-client=1.6.14
2.kernel dead(Kernel error)
报错信息如下:
Traceback (most recent call last):
File "C:ProgramDataAnaconda2libsite-packagestornadoweb.py", line 1512, in _execute
result = yield result
File "C:ProgramDataAnaconda2libsite-packagestornadogen.py", line 1055, in run
value = future.result()
File "C:ProgramDataAnaconda2libsite-packagestornadoconcurrent.py", line 238, in result
raise_exc_info(self._exc_info)
File "C:ProgramDataAnaconda2libsite-packagestornadogen.py", line 1063, in run
yielded = self.gen.throw(*exc_info)
File "C:ProgramDataAnaconda2libsite-packagesnotebookservicessessionshandlers.py", line 73, in post
type=mtype))
File "C:ProgramDataAnaconda2libsite-packagestornadogen.py", line 1055, in run
value = future.result()
File "C:ProgramDataAnaconda2libsite-packagestornadoconcurrent.py", line 238, in result
raise_exc_info(self._exc_info)
File "C:ProgramDataAnaconda2libsite-packagestornadogen.py", line 1063, in run
yielded = self.gen.throw(*exc_info)
File "C:ProgramDataAnaconda2libsite-packagesnotebookservicessessionssessionmanager.py", line 79, in create_session
kernel_id = yield self.start_kernel_for_session(session_id, path, name, type, kernel_name)
File "C:ProgramDataAnaconda2libsite-packagestornadogen.py", line 1055, in run
value = future.result()
File "C:ProgramDataAnaconda2libsite-packagestornadoconcurrent.py", line 238, in result
raise_exc_info(self._exc_info)
File "C:ProgramDataAnaconda2libsite-packagestornadogen.py", line 1063, in run
yielded = self.gen.throw(*exc_info)
File "C:ProgramDataAnaconda2libsite-packagesnotebookservicessessionssessionmanager.py", line 92, in start_kernel_for_session
self.kernel_manager.start_kernel(path=kernel_path, kernel_name=kernel_name)
File "C:ProgramDataAnaconda2libsite-packagestornadogen.py", line 1055, in run
value = future.result()
File "C:ProgramDataAnaconda2libsite-packagestornadoconcurrent.py", line 238, in result
raise_exc_info(self._exc_info)
File "C:ProgramDataAnaconda2libsite-packagestornadogen.py", line 307, in wrapper
yielded = next(result)
File "C:ProgramDataAnaconda2libsite-packagesnotebookserviceskernelskernelmanager.py", line 148, in start_kernel
super(MappingKernelManager, self).start_kernel(**kwargs)
File "C:ProgramDataAnaconda2libsite-packagesjupyter_clientmultikernelmanager.py", line 110, in start_kernel
km.start_kernel(**kwargs)
File "C:ProgramDataAnaconda2libsite-packagesjupyter_clientmanager.py", line 258, in start_kernel
**kw)
File "C:ProgramDataAnaconda2libsite-packagesjupyter_clientmanager.py", line 203, in _launch_kernel
return launch_kernel(kernel_cmd, **kw)
File "C:ProgramDataAnaconda2libsite-packagesjupyter_clientlauncher.py", line 128, in launch_kernel
proc = Popen(cmd, **kwargs)
File "C:ProgramDataAnaconda2libsubprocess.py", line 390, in init
errread, errwrite)
File "C:ProgramDataAnaconda2libsubprocess.py", line 640, in _execute_child
startupinfo)
WindowsError: [Error 2]
原因是python2.7和python3.6反复安装卸载的缘故(即Anaconda2和Anaconda3反复安装卸载的缘故),导致jupyter notebook没有读到正确的python 内核路径,解决方法如下:
(1)在Anaconda Prompt中输入语句(对windows而言,linux或Max直接在终端输入查看)
jupyter kernelspec list
查看安装的内核及其位置,如果是反复安装会显示Python2和Python3两个内核及其所在路径
(2)进入内核所在的目录,打开里面的kernel.jason文件,查看Python编译器的路径是否正确
我现在安装的是Anaconda2,所对应的应该是Python2,所以直接把Python3那个文件夹删了,然后打开Python2文件夹中的kernel.jason文件时,发现内核路径是错的:
{
"display_name": "Python 2",
"language": "python",
"argv": [
"C:\ProgramData\Anaconda3\envs\py2\python.exe",
"-m",
"ipykernel_launcher",
"-f",
"{connection_file}"
]
}
我的Anaconda2安装的路径是C:ProgramDataAnaconda2,其中的python.exe也在此根目录下,所以修改kernel.jason为:
{
"display_name": "Python 2",
"language": "python",
"argv": [
"C:\ProgramData\Anaconda2\python.exe",
"-m",
"ipykernel_launcher",
"-f",
"{connection_file}"
]
}
保存后重新打开jupyter notebook就不再显示kernel error了。
注意有可能,你的Kernel还是显示的Kernel error,原因在于你选择的是python3内核,切换到python2就可以了(但如果你像我一样删除了Python3文件夹,jupyter notebook里是不会再显示python3内核的)。
注:
Anaconda2-4.1.1-Windows-x86_64.exe下载链接
https://download.csdn.net/download/qq_21368481/10298381
Anaconda3-5.1.0-Windows-x86_64.exe下载链接
https://download.csdn.net/download/qq_21368481/10296836
最后
以上就是长情航空为你收集整理的Anaconda2和Anaconda3反复安装出现的问题的解决方法的全部内容,希望文章能够帮你解决Anaconda2和Anaconda3反复安装出现的问题的解决方法所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
发表评论 取消回复