跳转至

Jupyter使用指南

使用方法

  • 本机预装环境中都已经安装jupyter notebook;
  • 需要进入到anaconda环境中,添加环境名称到jupyter内核中,之后启动jupyter;
  • 启动成功后选择好项目,在 Kernel 菜单中选择内核(即conda环境名称)即可;

添加新环境到 jupyter notebook

环境安装成功后不会出现在 jupyter notebook 中,需要手动添加

  • 在终端中切换到虚拟环境

    conda activate <env_name>               # <env_name> 表示环境名称
    

  • 添加虚拟环境到 jupyter 中

    # Windows 系统执行
    python -m ipykernel install --name=<env_name>
    
    # Ubuntu 系统执行
    python -m ipykernel install --user --name=<env_name>
    

  • 启动 jupyter

    jupyter notebook                # 启动成功浏览器会自动打开
    

远程端口访问

  • 若想使用远程端口访问 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 内容