跳转至

jupyter notebook使用指南

使用方法

  • 本机预装环境中都已经安装jupyter notebook;
  • 使用终端输入 jupyter notebook启动或者点击 开始菜单 -> anaconda3 -> jupyter notebook 即可启动(限windows),浏览器会自动打开;
  • 打开后选择好项目,在 Kernel 菜单中选择内核(即conda环境名称)即可;

添加新环境到 jupyter notebook

在 conda 中新建的环境不会出现在 jupyter notebook 中,需要手动添加

  • 在终端中切换到虚拟环境
    conda activate <env_name>
    
  • 安装 ipykernel

    pip install ipykernel
    

  • 添加虚拟环境到 jupyter notebook 中

    python -m ipykernel install --name <env_name>
    

远程端口访问

  • 若想使用远程端口访问 jupyter notebook,请在终端中使用如下命令启动 jupyter notebook

    jupyter notebook --ip=0.0.0.0 --port=7860 --allow-root
    

  • 启动成功后终端界面中会输出一串类似如下的内容:

    http://127.0.0.1:7860/tree?token=7cda9223ab205e397c2a6c4473402baee0e73d1829850ed6
    
    请复制该内容发送给客服人员开通远程访问权限;

常见问题

在使用 jupyter notebook 的过程如果遇见浏览器一直上下跳动的问题,大多是因为您的代码 pinrt 打印内容太多导致,请修改代码避免出现大量 print 内容