CentOS7 remote link jupyter AND how to use jupyter

#遠程連接jupyter 

1.安裝anaconda

2.生成配置文件 #jupyter notebook --generate-config

[root@50eb5057baac /]# jupyter notebook --generate-config  
Writing default config to: /root/.jupyter/jupyter_notebook_config.py 

3.生成jupyter密碼

Enter password:   youpasswd
Verify password:   youpasswd(confirm),生成加密後的密碼

root@mycount/]# ipython  
Python 3.5.1 (default, Oct 21 2016, 21:37:19)   
Type 'copyright', 'credits' or 'license' for more information  
IPython 6.2.1 -- An enhanced Interactive Python. Type '?' for help.  
  
In [1]: from notebook.auth import passwd  
  
In [2]: passwd()  
Enter password:   
Verify password:   
Out[2]: 'sha1:adfdagegweghwsgghwrhno5454554bvshedhehe'  
  
In [3]:quit()   

4.修改配置文件,命令:

[root@localhost ~]# vi /root/.jupyter/jupyter_notebook_config.py 

5.填寫配置信息 

c.NotebookApp.ip='*' #設置訪問notebook的ip,*表示所有IP,這裏設置ip爲都可訪問  
c.NotebookApp.password = u'sha1:fdfdfsgergwgwg598745ghrgrgsgsgsg' #填寫剛剛生成的密文  
c.NotebookApp.open_browser = False # 禁止notebook啓動時自動打開瀏覽器(在linux服務器一般都是ssh命令行訪問,沒有圖形界面的。所以,啓動也沒啥用)  
c.NotebookApp.port =8888 #指定訪問的端口,默認是8888。
c.NotebookApp.notebook_dir = '/home/chen/tensorfile' #更改默認jupyter打開文件(無,則默認爲anaconda安裝的文件夾)

6.啓動jupyter notebook 命令 # jupyter notebook --allow-root   或  #jupyter notebook --allow-root&(後臺掛起運行)

[root@localhost ~]# jupyter notebook --allow-root

[W 10:53:38.866 NotebookApp] WARNING: The notebook server is listening on all IP addresses and not using encryption. This is not recommended.
[I 10:53:38.926 NotebookApp] JupyterLab beta preview extension loaded from /root/anaconda3/lib/python3.6/site-packages/jupyterlab
[I 10:53:38.927 NotebookApp] JupyterLab application directory is /root/anaconda3/share/jupyter/lab
[I 10:53:38.933 NotebookApp] Serving notebooks from local directory: /root
[I 10:53:38.933 NotebookApp] 0 active kernels
[I 10:53:38.933 NotebookApp] The Jupyter Notebook is running at:
[I 10:53:38.933 NotebookApp] http://localhost.localdomain:8888/
[I 10:53:38.934 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
[I 10:53:43.575 NotebookApp] 302 GET / (10.0.93.184) 0.99ms
[I 10:53:43.579 NotebookApp] 302 GET /tree? (10.0.93.184) 1.05ms

7.瀏覽器訪問:http://yourip:8888/,輸入密碼:

8.進入(默認文件路徑【如下圖顯示的文件夾】可以在配置文件中更改,如上面第5步中最後一行):

 9.如果訪問出錯,關閉linux防火牆,service iptables stop關閉,service iptables start開啓

        *. 永久性生效

        開啓:chkconfig iptables on

        關閉:chkconfig iptables off

        *. 即時生效,重啓後失效

        開啓:service iptables start

        關閉:service iptables stop

[root@localhost ~]# service iptables stop
Redirecting to /bin/systemctl stop iptables.service
Failed to stop iptables.service: Unit iptables.service not loaded.

10.如果提示:Failed to stop iptables.service: Unit iptables.service not loaded.則關閉防火牆失敗

centos7關閉防火牆有變化:systemctl stop firewalld.service          systemctl disable firewalld.service

[root@localhost ~]# systemctl stop firewalld.service
[root@localhost ~]# systemctl disable firewalld.service

Removed symlink /etc/systemd/system/multi-user.target.wants/firewalld.service.
Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.

systemctl命令戳: 這裏

#jupyter使用方法

1.新建文件,點擊new,確定python爲運行環境

2. 使用

 3.可以把jupyter文件轉換pdf和html等文件

5.下載之後瀏覽器打開長這樣:

詳細使用jupyter可以參考:這裏

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章