在服务器上配置jupyter, 方便我们远程登录.
第一步:安装jupyter, pip3 install jupyter (此处使用的是python3)
第二步:生成配置文件jupyter notebook --generate-config
gz@ubuntu:~$ cd .jupyter/
gz@ubuntu:~/.jupyter$ ll
total 12
drwxr-xr-x 2 gz gz 4096 Sep 3 14:56 ./
drwxr-xr-x 36 gz gz 4096 Sep 4 11:28 ../
-rw-r--r-- 1 gz gz 26 Sep 3 14:56 migrated
gz@ubuntu:~/.jupyter$ jupyter notebook --generate-config
jupyter: command not found
gz@ubuntu:~/.jupyter$ workon py3_face
(py3_face) gz@ubuntu:~/.jupyter$ jupyter notebook --generate-config
Writing default config to: /home/gz/.jupyter/jupyter_notebook_config.py
(py3_face) gz@ubuntu:~/.jupyter$ ll
total 48
drwxr-xr-x 2 gz gz 4096 Sep 4 11:35 ./
drwxr-xr-x 36 gz gz 4096 Sep 4 11:28 ../
-rw-rw-r-- 1 gz gz 33341 Sep 4 11:35 jupyter_notebook_config.py
-rw-r--r-- 1 gz gz 26 Sep 3 14:56 migrated
(py3_face) gz@ubuntu:~/.jupyter$
>>> from notebook.auth import passwd
>>> passwd()
Enter password:
Verify password:
'sha1:xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
>>>
vim + ~/.jupyter/jupyter_notebook_config.py
c.NotebookApp.ip="192.168.xxx.xxx"
c.NotebookApp.password = u"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" # 刚才复制的那个密文
c.NotebookApp.open_brower = False # # 禁止自动打开浏览器
c.NotebookApp.port = 8888 #随便指定一个端口
这里注意:c.NotebookApp.ip='104.222.1.1',这里应该填写你服务器的ip,网上的全部都是c.NotebookApp.ip='*',我照着测试后踩了很多坑。
物理机打开浏览器
输入
http://192.168.xxx.xxx:8888/
输入前面设置的密码。