美文网首页石晔
jupyter notebook 服务器远程配置

jupyter notebook 服务器远程配置

作者: yesski | 来源:发表于2018-10-24 11:40 被阅读0次

    服务器上开发,用jupyter比纯vi开发更舒服,且能直观看到变量,很适合科学计算,数据学科得使用

    但是由于服务器关闭了图形界面,所以在服务器上安装Jupyter Notebook,通过ssh远程访问,在本机web访问,利用本机的显卡,还可以执行plt相关图形命令

    顺序如下

    首先,没有jupyter的话,一般是没装蟒蛇  安装一个就好

    连接服务器,然后执行

    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

    2. 生成密码

    自动生成

    从 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

    手动生成

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

    In [1]: from notebook.auth import passwd

    In [2]: passwd()

    Enter password:

    Verify password:

    Out[2]: 'sha1:67c9e60bb8b6:9ffede0825894254b2e042ea597d771089e11aed'

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

    c.NotebookApp.password = u'sha1:67c9e60bb8b6:9ffede0825894254b2e042ea597d771089e11aed'

    3. 修改配置文件

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

    c.NotebookApp.ip='*'

    c.NotebookApp.password = u'sha:ce...刚才复制的那个密文'

    c.NotebookApp.open_browser = False

    c.NotebookApp.port =8888 #可自行指定一个端口, 访问时使用该端口

    以上设置完以后就可以在服务器上启动 jupyter notebook,jupyter notebook, root 用户使用 jupyter notebook --allow-root。打开 IP:指定的端口, 输入密码就可以访问了。

    需要注意的是不能在隐藏目录 (以 . 开头的目录)下启动 jupyter notebook, 否则无法正常访问文件。

    相关文章

      网友评论

        本文标题:jupyter notebook 服务器远程配置

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