• 操作环境
    • 主机1:Windows 10
    • 主机2:Ubuntu 24.2

安装Jupyter

  1. 登录到主机2:
    1
    ssh <username>@<IP addr>
    其中,<username>为主机2的用户名,<IP addr>为主机2的IP地址,随后输入主机2用户的密码即可登录到主机2
  2. 主机2切换到conda环境:
    1
    conda activate <env_name>
    其中,<env_name>为你的conda环境的名称
  3. 安装jupyter notebook,本案例安装版本为 7.x.x
    1
    pip install jupyter -i https://mirrors.tuna.tsinghua.edu.cn/pypi/web/simple
    其中,-i后面填入镜像源位置

配置Jupyter环境

  1. 生成Jupyter配置文件
    1
    jupyter notebook --generate-config
    生成的配置文件的路径为<用户目录>/.jupyter/jupyter_notebook_config.py文件
  2. 编辑配置文件
    1
    2
    3
    c.ServerApp.allow_remote_access = True   # 设置远程连接
    c.ServerApp.port = 8888 # 设置端口号
    c.ServerApp.root_dir = 'your jupyter home dir' # 进入jupyter的默认路径
  3. 设置Jupyter登录密码(此版本为7.x.x)
    1
    jupyter notebook passward
    之后输入密码即可

远程连接Jupyter服务器

  1. 启动主机2的Jupyter服务器
    1
    jupyter notebook
  2. 在主机1上使用SSH映射到主机2的Jupyter
    1
    ssh -N -f -L localhost:<host1 port>:localhost:<host2 port> <username>@<host2 IP Addr>
    其中<host1 port>为主机1的任意端口,<host2 port>为主机2的Jupyter服务器的端口,<username>为主机2的用户名,<host2 IP Addr>是主机2的IP地址,映射完的窗口不要关
  3. 在主机1上访问上一步输入的localhost:<host1 port>,输入设置的密码即可登录远程Jupyter服务器

配置Jupyter编辑器

菜单栏Setting >> Editor Setting勾选选项Show the documentation pannel(显示帮助文档),Enable autocompletion(代码自动补全)