Jupyter Notebook7 远程访问配置及汉化、自动补全

Jupyter Notebook 远程访问配置

  1. 创建虚拟环境

    conda create -n test python=3.9
  2. 进入虚拟环境

    conda activate test
  3. 安装jupyter

    pip install jupyter
  4. 设置登陆密码

    ipython #进入交互模式
    
    # jupyter-server 最近发布了新的版本升级
    【新】	#jupyter notebook7
    from jupyter_server.auth import passwd;
    passwd(algorithm='sha1')
    Enter password:
    Verify password:
    Out[2]: 'sha1:...'		#此处需要记下来
    
    【旧】 # jupyter notebook6
    from notebook.auth import passwd
    passwd(algorithm='sha1')
    Enter password:
    Verify password:
    Out[2]: 'sha1:...'		#此处需要记下来
  5. 生成配置文件

    jupyter notebook --generate-config

    自动在根目录下生成文件(~/.jupyter/jupyter_notebook_config.py)

  6. 修改配置文件

    vim ~/.jupyter/jupyter_notebook_config.py
    
    【新】
    c.ServerApp.ip = '0.0.0.0'
    c.ServerApp.password = ''
    c.ServerApp.open_browser = False
    c.ServerApp.port = 8888		#若端口被占用可以视情况改
    c.ServerApp.allow_remote_access = True
    
    【旧】
    c.NotebookApp.ip = '0.0.0.0' 
    c.NotebookApp.password = ''
    c.NotebookApp.open_browser = False
    c.NotebookApp.port = 8888
    c.NotebookApp.allow_remote_access = True
  7. 远程启动jupyter notebook

    1. 方法一
      jupyter notebook --ip=0.0.0.0 --no-browser --allow-root

      但这种会一直占着窗口,无法执行其他命令。Ctrl + C 即可结束

    2. 方法二
      nohup jupyter notebook --ip=0.0.0.0 --no-browser --allow-root> jupyter_notebook.log 2>&1 &

      后台挂起运行,将运行日志重定向到当前目录下jupyter_notebook.log文件中。执行完之后会返回一行代码pid记住,结束进程的时候会用到。

      需要手动结束 kill -9 {对应pid}

Jupyter Notebook7汉化、自动补全

  1. 汉化

    #pip安装方式
    pip install jupyterlab-language-pack-zh-CN
    #conda安装方式
    conda install -c conda-forge jupyterlab-language-pack-zh-CN

  2. 代码自动补全

    设置➡设置编辑器➡代码补全➡启用自动补全

  • 2
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值