痛苦流涕没卸!小菜鳥歷時(shí)很多很多天约计,今天終于成功在服務(wù)器上裝上了能用的jupyter耕挨!本文十二萬分感謝此篇教程:Linux 服務(wù)器上部署搭建 Jupyter notebook【詳細(xì)教程】_W_nihao_123456的博客-CSDN博客
一筒占、miniconda3的安裝:清華鏡像安裝最新版本
Index of /anaconda/miniconda/ | 清華大學(xué)開源軟件鏡像站 | Tsinghua Open Source Mirror
1. 軟件下載與安裝
#軟件下載
wget -c https://mirrors.tuna.tsinghua.edu.cn/anaconda/miniconda/Miniconda3-py39_4.9.2-Linux-x86_64.sh
#軟件安裝
bash Miniconda3-py39_4.9.2-Linux-x86_64.sh
按照shell界面提示進(jìn)行安裝即可。
注意:不建議通過conda init進(jìn)行初始化奏窑,因?yàn)榭赡軙?huì)導(dǎo)致conda與系統(tǒng)里的軟件相沖突
2. 啟動(dòng)conda 環(huán)境:(每次都需要)
source ~/miniconda3/bin/activate
3. 添加國內(nèi)鏡像盛卡,進(jìn)入清華鏡像源anaconda頁面:
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/bioconda
conda config --set show_channel_urls true
4. 更新環(huán)境
# 查看版本
conda -V
# 更新conda環(huán)境
conda update -n base conda
# 更新conda的所有包
conda update --all
注意:添加完鏡像之后一定一定要更行環(huán)境并村,不然會(huì)出現(xiàn)下列報(bào)錯(cuò):
Solving environment: failed with initial frozen solve. Retrying with flexible solve.
二哩牍、Jupyter的配置
1.安裝jupyter
conda install jupyterlab #安裝jupyter
jupyter notebook --generate-config #生成jupyter配置文件
該命令執(zhí)行后會(huì)生成一個(gè)./jupyter/jupyter_notebook_config.py的文件丸边,你需要打開該文件妹窖,該文件的位置基本就是在本目錄骄呼,較為容易找到蜓萄。
2.修改Jupyter_notebook_config.py該配置文件
c.NotebookApp.ip = '' # 設(shè)置訪問IP
c.NotebookApp.open_browser = False # 默認(rèn)不自動(dòng)打開瀏覽器
c.NotebookApp.password = '' # 輸入剛剛生成的密鑰
c.NotebookApp.port = 8888 # 設(shè)置端口, 其他端口應(yīng)該也是可以的
c.NotebookApp.notebook_dir = '' # 設(shè)置Jupyternotebook 打開的根目錄
(1)上述代碼c.NotebookApp.ip = ''的設(shè)置,需要你在你的linux服務(wù)器上運(yùn)行ifconfig命令臣咖,可以看到一個(gè)或多個(gè)ip地址夺蛇,選擇一個(gè)填入即可,如我選的是 10.42.1.181
(2)上述代碼c.NotebookApp.password = ''的設(shè)置,需要你在服務(wù)器上依次執(zhí)行如下命令:
python #調(diào)用python
#以下是python
>>> from notebook.auth import passwd
>>> passwd()
Enter password:
Verify password:
'argon2:$argon2id$v=19$m=10240,t=10,p=8$HgQc0YPTuS+ylod6fgdWXw$HKYXUwUXM7JGikCwW+kuLg' #將這串密碼保存下來,放入c.NotebookApp.password = ''里面
然后運(yùn)行完passwd()之后會(huì)得到一串密碼牺氨,你需要將這串密碼保存下來猴凹,放入c.NotebookApp.password = ''里面沼头。
(3)上述代碼c.NotebookApp.notebook_dir = ''的設(shè)置进倍,這里你需要在引號(hào)中加入路徑即可。
執(zhí)行完之后你就得到了如下的內(nèi)容:
c.NotebookApp.ip = 'xx.xx.xx.xx' # 設(shè)置訪問IP
c.NotebookApp.open_browser = False # 默認(rèn)不自動(dòng)打開瀏覽器
c.NotebookApp.password = 'xxxxxxx' # 輸入剛剛生成的密鑰
c.NotebookApp.port = 8888 # 設(shè)置端口毡庆, 其他端口應(yīng)該也是可以的
c.NotebookApp.notebook_dir = 'xxxxxxx' # 設(shè)置Jupyternotebook 打開的根目錄
將這些內(nèi)容全部追加到j(luò)upyter_notebook_config.py文件末尾么抗,保存文件。
三吞琐、運(yùn)行Jupyter notebook
今天最令小菜雞激動(dòng)人心的時(shí)刻到了!E印切诀!
1. 運(yùn)行如下命令打開Jupyter
jupyter notebook
將網(wǎng)站復(fù)制到瀏覽器中幅虑,輸入剛剛自己設(shè)置的密碼褒墨,就好啦C餐ぁ!!成功M科ā2鹩帧!
2. 添加R內(nèi)核
進(jìn)入R shell:
install.packages(c('IRkernel','repr', 'IRdisplay', 'evaluate', 'crayon', 'pbdZMQ', 'devtools', 'uuid', 'digest'))
IRkernel::installspec() #只在當(dāng)前用戶安裝
然后重啟或者刷新jupyter就可以看到R啦@刚恕L濉!媽呀感動(dòng)5簿簟J恪茶鹃!
3. jupyter小組件Conda和Nbextensions
在終端中輸入以下命令:
pip install jupyter_contrib_nbextensions #Nbextensions
jupyter-contrib-nbextension install --user
conda install nb_conda #安裝nb_conda
撒花;恋瘛!闭翩!
感恩以下無私分享的人兒們的分享:
Jupyter notebook中配置R語言_weixin_43659913的博客-CSDN博客
Linux 服務(wù)器上部署搭建 Jupyter notebook【詳細(xì)教程】_W_nihao_123456的博客-CSDN博客