部署远程jupyter

1、直接执行

pip3 install jupyter

2、无法执行jupyter notebook后报错

“jupyter:command not found”

3、找到安装的位置,一般都在python3的目录下

cd /usr/local/python3/bin

4、将下面的命令添加到 ~/.bash_profile 中

export PATH=/usr/local/python3/bin:$PATH

5、执行的时报错

OSError: [Errno 99] Cannot assign requested address

6、寻找解决方案

https://www.cnblogs.com/faramita2016/p/7512471.html

使用jupyter notebook --ip=0.0.0.0 --no-browser --allow-root启动

7、进入python3创建密码

[root@Dao ~]#ipython
Python 3.6.5 (default, Apr 16 2019, 14:58:48) 
Type 'copyright', 'credits' or 'license' for more information
IPython 7.5.0 -- An enhanced Interactive Python. Type '?' for help.

In [1]: from notebook.auth import passwd                                                       

In [2]: passwd()                                                                               
Enter password: 
Verify password: 
# 然后就会生成秘钥,记得复制下来,配置密码的时候要用到
Out[2]: 'sha1:40ad5fc36b7a:8ff22a722b50b87a75d9e39017039594ade1fe47'

7、创建jupyter配置文件

jupyter notebook --generate-config
Writing default config to: /root/.jupyter/jupyter_notebook_config.py

8、编辑配置文件

c.NotebookApp.ip='*'                  # 就是设置所有ip皆可访问
c.NotebookApp.password = u'sha:ce...'       # 刚才复制的那个密文'
c.NotebookApp.open_browser = False         # 禁止自动打开浏览器
c.NotebookApp.port =8888                #随便指定一个端口
c.NotebookApp.notebook_dir = u''          # 指定工作目录

9、生成测试认证

#此命令会在你的当前文件夹生成mycert.pem文件
openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout mycert.pem -out mycert.pem
#编辑jupyter_notebook_config.py 配置文件,添加如下配置
c.NotebookApp.certfile = u'路径名/mycert.pem'
10、测试启动
jupyter notebook --ip=0.0.0.0 --allow-root

浏览器访问https://ip:8888,注意一定要用https协议,http是访问不了的

11、正式证书的配置

#添加如下配置
c.NotebookApp.certfile = u'/*.crt' #crt文件路径
c.NotebookApp.keyfile = u'/*.key' #key文件路径

12、后台运行

nohup jupyter notebook --ip=0.0.0.0 --no-browser --allow-root >> /root/notebook.log &

 

 

 

posted @ 2019-04-29 18:01  游小刀  阅读(783)  评论(0编辑  收藏  举报
levels of contents