jupyter notebook安装多kernel

    技术2024-01-16  135

    查看Jupyter Notebook使用的是哪一个Python解释器

    import sys print(sys.version) print(sys.executable)

    Jupyter Notebook内核指定的Python环境位置,在cmd(win+r)下输入命令:

    ipython kernelspec list

    可以直接修改里面的配置

    更改pip源:

    pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple

    可选国内源: 豆瓣:http://pypi.douban.com/simple/ 中科大:https://pypi.mirrors.ustc.edu.cn/simple/ 清华:https://pypi.tuna.tsinghua.edu.cn/simple 阿里云 http://mirrors.aliyun.com/pypi/simple/

    多个kernel安装步骤如下:

    创建python2.7版本虚拟环境

    conda create -n env_name python=2.7

    进入环境

    activate env_name

    添加到可选的kernel

    pip install ipykernel

    通过ipykernel为jupyter添加python2.7环境

    python -m ipykernel install --name env_name

    关闭python2.7环境

    deactivate

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

    删除 jupyter 内核

    jupyter kernelspec remove 'kernelname'
    Processed: 0.012, SQL: 9