先安裝jupyter notebook
pip install ipython
pip install jupyter
創建一個目錄(jupyter notebook工作目錄)
mkdir jupyter_notebook
生成配置文件
jupyter-notebook --generate-config
生成密碼
from notebook.auth import passwd
passwd()
會生成一個sha1加密的密碼 這個后面要用 保存一下
修改配置文件
vim /root/.jupyter/jupyter_notebook_config.py
在jupyter_notebook_config.py中最下面添加一下配置
c.NotebookApp.ip='*' # *代表所有機器都可訪問,或者輸入服務ip
c.NotebookApp.password = u'sha1:......' # 把引號中的內容替換為剛剛生成的sha1開頭的密碼
c.NotebookApp.notebook_dir = u'/root/jupyter_notebook' # 第一步創建的工作目錄
c.NotebookApp.open_browser = False
c.NotebookApp.port = 8888
c.NotebookApp.allow_root = True
:wq 保存退出
修改密碼並啟動服務
由於上面生成的密碼太長,所以修改一個簡單的密碼
jupyter notebook password
輸入2次新密碼
為了使密碼生效,防止jupyter notebook不允許以root方式啟動,我們需要在首次訪問需要加入參數
nohup jupyter-notebook --allow-root --config=/root/.jupyter/jupyter_notebook_config.py &
第二次啟動就不用--config這個參數了
nohup jupyter-notebook --allow-root &啟動即可
打開瀏覽器輸入ip:8888就可以看到jupyter notebook的頁面了
輸入密碼就可以使用jupyter notebook了