安裝:
pip install ipython
pip install "ipython[notebook]"
#或者
pip3 install ipython[all]
#用瀏覽器即時運行調試代碼
ipython notebook
修改啟動默認目錄:
jupyter notebook --generate-config
#Writing default config to: /root/.jupyter/jupyter_notebook_config.py
vim /root/.jupyter/jupyter_notebook_config.py
#修改以下行並打開注釋(刪除#)
c.NotebookApp.notebook_dir = '/root/python'
配置為服務器模式:
首先設置個啟動密碼,遠程登錄需要這個密碼:
jupyter notebook password
#Enter password:
#Verify password:
#[NotebookPasswordApp] Wrote hashed password to /root/.jupyter/jupyter_notebook_config.json
修改配置文件:
#c.NotebookApp.allow_origin = '*' #運行所有源訪問,默認為localhost。 此配置可不打開
#c.NotebookApp.ip = '127.0.0.1' #只監聽本地訪問
c.NotebookApp.ip = '0.0.0.0' #運行所有ip訪問
c.NotebookApp.port = 8080 # 運行端口
c.NotebookApp.open_browser = False # 運行 notebook 應用時不打開瀏覽器
或者直接:
iptables -I INPUT 1 -p tcp --dport 8080 -j ACCEPT #開通防火牆端口
jupyter notebook --ip 0.0.0.0 --no-browser --port=8080 --allow-root
#后台:
nohup jupyter notebook & #將輸出和錯誤信息輸出到控制台
nohup jupyter notebook > /dev/null 2>&1 & #將輸出和錯誤信息丟棄
nohup jupyter notebook > info 2> error & #將輸出和錯誤信息分別輸出到文件
#nohup確保這個進程在斷開 ssh 連接后依舊運行,& 讓進程在后台運行。如果想終止 notebook 應用,請找到含有 jupyter-notebook 的進程,並用 kill 殺掉它。
微軟倉庫:
https://notebooks.azure.com/xuejianbest/libraries/iptest
安裝模塊用:
!pip install ...