• jupyter notebook远程配置


    服务器端配置

    • 在服务器生成jupyter配置文件
    $jupyter notebook --generate-config
    

    生成之后会得到配置文件的路径

    • 启动jupyter,设置密码
    In [1]: from notebook.auth import passwd
    In [2]: passwd()
    

    输入、确认密码之后,得到了密文'shal:...'

    • 修改配置文件

    打开之前生成的配置文件

    添加如下代码:

    c.NotebookApp.ip = '*'
    c.NotebookApp.password = u'shal:...' #之前生成的密文
    c.NotebookApp.open_browser = False
    c.NotebookApp.port = 3456 #随便一个端口就可以
    
    • 重启jupyter

    如果用terminal启动,不会弹出浏览窗口。

    服务器端配置完成

    本地配置

    注:服务器端启动jupyter的terminal窗口不要关闭

    在本地直接访问 http://服务器地址:3456 ,输入密码就可以进入jupyter了。

    修改jupyter的python环境

    注:在本地打开的jupyter页面本质上是服务器端的,所以设置的python环境也应为服务器端的。

    • 安装ipykernel
    pip install ipykernel
    
    python -m ipykernel install --user --name python3.6 --display-name "python 3.6"
    

    --name后为环境名称

    --display-name后为在jupyter中显示的名字

    jupyter自动补全

    注:均在服务器端进行安装

    • 安装nbextensions
    pip install jupyter_contrib_nbextensions -i https://pypi.mirrors.ustc.edu.cn/simple
    jupyter contrib nbextension install --user
    
    • 安装nbextensions_configurator
    pip install --user jupyter_nbextensions_configurator 
    jupyter nbextensions_configurator enable --user
    
    • 重启jupyter notebook

    此时主页会多出Nbextensions按钮,点击后勾选Hinterland,重启jupyter就开启自动补全了。

    注:自动补全可能会与远程访问有冲突(不清楚原理),在自动补全配置完成之后,重启服务器端jupyter,可能会有如下错误:

    Traceback (most recent call last):
      File "/data/xxxxxx/anaconda3/envs/python3.6/lib/python3.6/site-packages/traitlets/traitlets.py", line 528, in get
        value = obj._trait_values[self.name]
    KeyError: 'allow_remote_access'
    ......
    

    在最开始生成的配置文件中加入

    c.NotebookApp.allow_remote_access = True
    

    重启jupyter即可。

  • 相关阅读:
    [code]图像亮度调整enhancement
    另类安装系统——PE工具提取
    重置路由器密码
    苹果系统安装——虚拟机体验
    Cisco模拟器使用和静态路由配置
    Cisco基本命令配置
    server——小记
    关于server的一些小记
    计算机术语
    CCNA长语
  • 原文地址:https://www.cnblogs.com/racso/p/10408620.html
Copyright © 2020-2023  润新知