tmux+jupyter-notebook后臺保存python運行空間

1. jupyter-notebook安裝

Project Jupyter | Installing Jupyter

install

創(chuàng)建一個新的環(huán)境用于jupyter notebook運行:conda create -n jupyter python
按照官方教程安裝jupyter即可。

2. jupyter notebook配置

對jupyter進行一定的配置可以方便我們使用,尤其是遠程訪問服務(wù)器。
主要參考博客:【隨記】服務(wù)器安裝并配置jupyter notebook,并使用vscode擴展進行連接 - 氫離子活度指數(shù) - 博客園

2.1 在python中設(shè)定passwd

from jupyter_server.auth import passwd
passwd()
#然后會讓你輸出密碼,確認(rèn)密碼,以及返回密鑰數(shù)據(jù),備份返回的密鑰信息。

2.2 創(chuàng)建jupyter配置文件

運行jupyter notebook --generate-config生成jupyter環(huán)境配置文件(默認(rèn)在~/.jupyter/jupyter_notebook_config.py,同目錄下json文件是密鑰hash)

2.3 修改jupyter環(huán)境配置文件中以下配置項

c.ServerApp.ip='0.0.0.0'
c.ServerApp.password=u'sha1****' #就之前保存的驗證密碼
c.ServerApp.open_browser =False # 設(shè)置是否自動打開瀏覽器
c.ServerApp.port =8889  # 設(shè)置端口
c.ServerApp.allow_remote_access = True
c.ServerApp.root_dir = 'xxxxxxx' # 配置默認(rèn)訪問的目錄

2.4 啟動jupyter服務(wù)

即用即啟,占用一個shell,用后關(guān)閉:jupyter notebook --allow-root

2.5 vscode中使用(暫時還沒有配置)

待續(xù)

3. tmux中運行jupyter notebook

conda install -c conda-forge tmux
tmux new -s jp
jupyter notebook --allow-root
 #http://Phenix:8889/tree

復(fù)制url到瀏覽器即可。如果按照步驟2準(zhǔn)確配置了jupyter,那么無需輸入密碼即可進入。

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容