问题
- 在jupyter notebook中将kernel从python3切换到python2时,出现
Could not find a kernel matching Python 2. Please select a kernel
的错误
解决方法
- 查看已有的ipykernel环境
jupyter kernelspec list
如下图所示,表明python3的ipython内核已安装
Available kernels:
python3 /home/ozh/.local/share/jupyter/kernels/python3
- 安装python2环境
conda create --name pythonn27 python=2.7 - 切换python环境
source activate python27 - 安装ipython内核
conda install ipykernel - 配置内核
python -m ipykernel install --user - 查看内核文件指向python版本
位置:~/.local/share/jupyter/kernels/python2/kernel.json
{
"display_name": "Python 2",
"language": "python",
"argv": [
"/home/ozh/anaconda3/envs/python27/bin/python",
"-m",
"ipykernel_launcher",
"-f",
"{connection_file}"
]
}