美文网首页
如何在Linux部署远程Jupyter

如何在Linux部署远程Jupyter

作者: 涨财司 | 来源:发表于2019-03-28 09:20 被阅读0次

    首先安装好Jupyter
    推荐下面两种方式安装
    1)使用pyenv安装好相应的python并创建虚拟环境
    2)直接使用虚拟环境安装

    step1:生成一个 notebook 配置文件

    默认情况下,配置文件 ~/.jupyter/jupyter_notebook_config.py 并不存在,需要自行创建

    #创建配置文件的命令:
    $ jupyter notebook --generate-config
    

    注:
      如果是 root 用户执行上面的命令,会发生一个问题:
      Running as root it not recommended. Use --allow-root to bypass.

      提示信息很明显,root 用户执行时需要加上 --allow-root 选项。
      jupyter notebook --generate-config --allow-config

      执行成功后,会出现下面的信息:
      Writing default config to: /root/.jupyter/jupyter_notebook_config.py

    step2. 生成密码

    生成密码的方式有两种:
    (1)自动生成
    从 jupyter notebook 5.0 版本开始,提供了一个命令来设置密码:jupyter notebook password,生成的密码存储在 jupyter_notebook_config.json。

    $ jupyter notebook password
    Enter password:  ****
    Verify password: ****
    [NotebookPasswordApp] Wrote hashed password to /Users/you/.jupyter/jupyter_notebook_config.json
    

    (2)手动生成
    除了使用提供的命令,也可以通过手动安装,我是使用的手动安装,因为jupyter notebook password 出来一堆内容,没耐心看。打开 ipython 交互命令行,执行下面内容:

    In [1]: from notebook.auth import passwd
    In [2]: passwd()
    Enter password:
    Verify password:
    Out[2]: 'sha1:67c9e60bb8b6:9ffede0825894254b2e042ea597d771089------'
    

    sha1:67c9e60bb8b6:9ffede0825894254b2e042ea597d771089------ 这一串就是要在 jupyter_notebook_config.py 添加的密码。

    step3. 修改配置文件

    在 jupyter_notebook_config.py 中找到下面的行,取消注释并修改。

    c.NotebookApp.ip='*' # 可能会出错,改成0.0.0.0
    c.NotebookApp.password = u'sha:ce...刚才复制的那个密文'
    c.NotebookApp.open_browser = False
    c.NotebookApp.port =8888 #可自行指定一个端口, 访问时使用该端口
    c.NotebookApp.notebook_dir = '/user/you/Jupyter' #修改默认工作目录

    step4.启动服务

    以上设置完以后就可以在服务器上启动 jupyter notebook,

    # 后台启动
    # 普通用户使用如下命令:
    $ jupyter notebook &
    # root用户使用如下命令:
    $ jupyter notebook --allow-root &
    

    打开 IP:指定的端口, 输入密码就可以访问了。


    阿里云推广:
    通用代金券领取链接:https://promotion.aliyun.com/ntms/yunparter/invite.html?userCode=qtyyc38p
    优惠链接:(总有一款适合你)
    1)【开年HI购季】爆款云产品5折:https://www.aliyun.com/acts/product-section-2019/new-users?userCode=qtyyc38p
    2)【助力企业上云】性能级主机2-5折:https://promotion.aliyun.com/ntms/act/enterprise-discount.html?userCode=qtyyc38p
    3)【全民云计算】云主机低至2折:https://promotion.aliyun.com/ntms/act/qwbk.html?userCode=qtyyc38p
    4)【商标注册服务】低至300元:https://tm.aliyun.com/?userCode=qtyyc38p
    5)【超高返现】购物车全产品返25%:https://promotion.aliyun.com/ntms/act/shoppingcart.html?userCode=qtyyc38p
    6)【阿里云自营建站】买一年送一年:https://www.aliyun.com/jianzhan/?userCode=qtyyc38p

    相关文章

      网友评论

          本文标题:如何在Linux部署远程Jupyter

          本文链接:https://www.haomeiwen.com/subject/tcsfbqtx.html