Windows7下Jupyter Notebook使用入門

目錄

一、Jupyter簡介

二、Jupyter安裝

   2.1 python 3安裝

   2.2 Jupyter 安裝

三、Jupyter使用示例

四、Jupyter常用命令

五、其他說明

 

一、Jupyter簡介

    Jupyter Notebook是一個交互式筆記本,由IPython Notebook演化而來,本質上是一個Web應用程序,通過Jupyter Notebook,你可以使用谷歌瀏覽器完成python開發工作、交互式演示python代碼的執行效果、進行可視化教學等。還可以將整個交互過程轉換爲pythonhtmlmarkdownPDF等多種格式的文件。也可以通過網絡,將python代碼及運行效果與朋友共享。

 

二、Jupyter Notebook安裝

    2.1 python 3的安裝(略)

    2.2 Jupyter安裝

       python3 -m pip install --upgrade pip  #更新

       python3 -m pip install jupyter    #安裝jupyter

       jupyter notebook  #運行notebook

 

三、Jupyter Notebook使用示例

    01-安裝jupyter-notebook

01-安裝jupyter-notebook.jpg

    02-安裝matplotlab

02-安裝matplotlab包.jpg

    03-運行jupyter-notebook

03-運行jupyter-notebook.jpg

    04-jupyter-notebook中,畫一條sin曲線

04-在jupyter-notebook中,畫一條sin曲線.jpg

    05-直接訪問本地8888端口,需要輸入密碼或token

05-直接訪問本地8888端口,需要輸入密碼或token.jpg

    06-token的獲取方式-jupyter notebook list

06-token的獲取方式-jupyter notebook list.png

    07-運行Python,使用passwd,生成sha1密碼

07-運行Python,使用passwd,生成sha1密碼.jpg

    08-修改過jupyter notebook配置文件後,重啓服務

08-修改過jupyter notebook配置文件後,重啓服務.png

    09-正常轉化爲PDF需要安裝Windows版本的Miktex,並且要設置好路徑,安裝擴展包

    09-正常轉化爲PDF需要安裝Windows版本的Miktex,並且要設置好路徑,安裝擴展包.png


四、Jupyter常用命令

jupyter --help  #查看jupyter幫助

jupyter notebook help  #查看notebook詳細的命令使用幫助

jupyter notebook #使用默認配置啓動notebook

jupyter notebook --generate-config #c:/Users/用戶/.jupyter/目錄下,創建默認配置文件jupyter_notebook_config.py

jupyter notebook list  #查看正在運行的jupyter服務器地址、token令牌、根目錄

jupyter notebook password  #修改notebook登錄密碼

jupyter nbconvert file1.ipynb --to pdf  #手工轉換ipynb文件爲PDF文件

jupyter nbconvert file1.ipynb --to html  #手工轉換ipynb文件爲html文件

 

五、其他說明

5.1 jupyter 除了jupyter notebook子命令以外,還有好多子命令,比如jupyter nbconvert / jupyter console 等,可用通過jupyter --help查看。

5.2 如果直接運行jupyter notebook 命令,系統會自動創建一個48位的token,並使用默認配置啓動notebook,用戶可以通過http://localhost:8888/?token=<48token >網址訪問notebook,每次退出並重啓notebook 服務端,系統會自動重新生成token

5.3 可以在運行jupyter notebookcmd控制檯中,獲取token信息,當通過網絡訪問jupyter notebook時,輸入該token,可登錄jupyter notebook

5.4 也可以使用jupyter notebook password 命令,創建一個訪問密碼,創建密碼以後,token方式會失效,只可以使用密碼方式訪問。同時會生成一個哈希密碼文件,路徑爲C:/Users/用戶/.jupyter/jupyter_notebook_config.json。重啓jupyter notebook服務端,密碼才生效。

5.5直接運行jupyter notebook命令,只能在本機訪問notebook。我們還可以帶IPPort參數啓動notebook,例:jupyter notebook --ip=192.168.1.123 --port=6789 ,可以通過http://192.168.1.123:6789地址,在其他電腦上訪問notebook

5.6 如果使用jupyter notebook --generate-config命令生成默認配置文件jupyter_notebook_config.py,我們也可以把IPport等信息寫入到該配置文件中,直接啓動jupyter notebook時,會讀取配置文件的內容。變量如下,

c.NotebookApp.ip = '192.168.1.123'

c.NotebookApp.port = 6789

5.7 直接將ipynb文件轉換爲htmlpy文件是沒有問題的,要轉換爲pdf文件會報錯,需要到https://miktex.org/download,下載安裝Miktexbasic-miktex-2.9.7021-x64.exe),並將C:\Program Files\MiKTeX 2.9\miktex\bin\x64路徑加入到系統Path路徑中。可以使用命令行方式轉換:jupyter nbconvert test.ipynb --to pdf ,也可以直接在notebook網站中打開test.ipynb文件,直接導出PDF文件。

 

 

參考鏈接:

Jupyter官網

https://jupyter.org/

https://jupyter-notebook.readthedocs.io/en/stable/

 

Jupyter Notebook介紹與入門

https://blog.csdn.net/ibelieveican2015/article/details/79024927

 

jupyter-使用及設置密碼

https://www.jianshu.com/p/b1189769aeb2

 

Windows下的Jupyter Notebook 安裝與自定義啓動(圖文詳解)

http://www.cnblogs.com/zlslch/p/6984403.html

 

爲什麼Jupyter Notebook會比其他工具更受歡迎?

http://m.elecfans.com/article/687743.html

 

jupyter安裝,修改登錄密碼,啓動

https://blog.csdn.net/hotpotbo/article/details/79130899

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