配置云服務(wù)器安全組
騰訊云服務(wù)器Ubuntu20.0安裝miniconda、jupyter,notebook設(shè)置中文和遠(yuǎn)程訪(fǎng)問(wèn)
這里租的是阿里云的云服務(wù)器,只改了安全組入方向TCP端口,這里開(kāi)放的端口必須包含之后jupyter設(shè)置的端口,不然可能訪(fǎng)問(wèn)不了
安裝jupyter
用conda安裝,miniconda的安裝之前已經(jīng)發(fā)過(guò)了,這里直接用了
# conda新建一個(gè)環(huán)境
conda create -n jupyter -y
# 激活jupyter環(huán)境
conda activate jupyter
# 安裝jupyter
conda install jupyter -y
配置jupyter遠(yuǎn)程訪(fǎng)問(wèn)
# 生成notebook配置文件
jupyter notebook --generate-config

image.png
# 打開(kāi)python,創(chuàng)建一個(gè)密文的密碼
python
from notebook.auth import passwd
passwd()
# 輸入密碼,再次輸入
exit()

image.png
# 修改默認(rèn)配置文件
vim ~/.jupyter/jupyter_notebook_config.py
# 插入下面的內(nèi)容,vim操作自行搜索
c.NotebookApp.ip='*'
c.NotebookApp.password=u'argon2:$argon2id$v=19$m=10240,t=10,p=8$OBOjmJ9BxdyrtuY4acfI9g$iwU6g+wQHTNeJJQ0DAjJXjj6azUpJ8oDFvjKxnqxfWw' # 上圖紅框里面內(nèi)容前面加u
c.NotebookApp.open_browser=False
c.NotebookApp.port=8888

image.png
# 運(yùn)行jupyter notebook(重啟Shell后要先進(jìn)入jupyter環(huán)境再運(yùn)行jupyter notebook)
jupyter notebook

image.png
在本機(jī)瀏覽器中輸入服務(wù)器IP地址+端口號(hào)

image.png
輸入上面紅框時(shí)設(shè)置的密碼

image.png
登錄成功,不過(guò)新建的時(shí)候只有python一個(gè)內(nèi)核
退出直接在 Xshell 里面退出就行
安裝R
# 安裝R,還是在jupyter環(huán)境下
conda install -c conda-forge r-base -y
conda install -c conda-forge r-irkernel -y
再運(yùn)行jupyter notebook進(jìn)入

image.png
安裝nb_conda(可選)
不同環(huán)境的內(nèi)核可以通過(guò)安裝nb_conda解決
conda install -c conda-forge nb_conda_kernels
再運(yùn)行jupyter notebook進(jìn)入

image.png
Jupyter Notebook擴(kuò)展插件(可選)
conda install -c conda-forge jupyter_contrib_nbextensions
conda install -c conda-forge jupyter_nbextensions_configurator
jupyter contrib nbextension install --user

image.png
選自己想要的插件就行了