遠程訪問虛擬機 jupyter notebook

在服務器上配置jupyter, 方便咱們遠程登陸.python

第一步:安裝jupyter, pip3 install jupyter (此處使用的是python3)shell

第二步:生成配置文件jupyter notebook --generate-configubuntu

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$

第三步:生成密鑰 打開python3vim

>>> 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/code

輸入前面設置的密碼。ip

相關文章
相關標籤/搜索