jupyter增加多版本python内核

由于python代码有的需要在python2.7版本执行,有的需要在python3版本执行,所以需要安装多个python环境。 

前提:已经安装了anaconda和python3(安装步骤参考:https://blog.csdn.net/flyer_tang/article/details/80363669

 

目的:为jupyter再添加python2.7版本内核环境

 安装步骤如下:

  • 创建python2.7版本虚拟环境
conda create -n env_name python=2.7

  • 进入环境
#  mac user :      
 source activate env_name
# windows user:  
 activate env_name

 

  • 添加到可选的kernel
pip install ipykernel

  • 通过ipykernel为jupyter添加python2.7环境
python -m ipykernel install --name env_name

 

  •  关闭python2.7环境
#  mac user : 
 deactivate
# windows user:  
 source deactivate

重新打开jupyter notebook可以看到python2.7版本的py27已经添加

 

猜你喜欢

转载自blog.csdn.net/flyer_tang/article/details/81305087