天天看點

Centos7安裝jupyter notebook

###安裝python3

#####檢視目前python版本

[[email protected] ~]# python -V
Python 2.7.5
           
安裝python3以及檢查python3的版本
yum install python3
python3 -V
           
安裝jupyter notebook
pip3 install jupyter
           

生成配置檔案

jupyter notebook --generate-config
Writing default config to: /root/.jupyter/jupyter_notebook_config.py
           

生成密碼,用剛裝好的python3就可以了(可能是版本問題,嘗試不能成功)

from notebook.auth import passwd
passwd()
           

指令行生成密碼:

jupyter notebook password 
#[NotebookPasswordApp] Wrote hashed password to /root/.jupyter/jupyter_notebook_c                     onfig.json
再次前台啟動就會出現哈希密碼
           

最後是修改一下配置檔案

password 就是剛才用指令行生成的哈希密碼

vim /root/.jupyter/jupyter_notebook_config.py
c.NotebookApp.password = 'sha1:8$E18FYIYkGfwYK+270oBdgA$gNYatshZbw8WvcoiwjPKMw'
c.NotebookApp.port = 8888
c.NotebookApp.ip = '*'
c.NotebookApp.open_browser = False
c.NotebookApp.notebook_dir = '/jupyter_notebook'
           
啟動jupyter notebook

前台啟動:

jupyter notebook --allow-root
           

背景啟動:

#預設将日志寫到目前目錄的nohup.out中
nohup jupyter notebook --allow-root &

#不想輸出日志可将日志輸出到“黑洞”(同時也可将null指定為輸出檔案)
nohup jupyter notebook --allow-root >/dev/null 2>&1 &
           

使用背景啟動想退出時:

想要退出的話可以查詢jupyter notebook占用了哪個程序

ps -aux | grep jupyter
           

或者是查詢端口号8888被哪個程序占用了

netstat -tunlp|grep 8888
           

然後把找到的程序kill掉就可以了

kill 33650