1.Jupyter introduction
The Jupyter Notebook is a web-based interactive computing platform. The notebook combines live code, equations, narrative text, visualizations
Refence to: https://jupyter.org/
2. linux下安装
2.1 使用conda安装较为方便
conda install jupyter notebook
2.2 使用pip安装
pip3 install jupyter
3. Jupyter 配置
3.1 基础文件配置
jupyter notebook --generate-config // produce configfiles calling ***"jupyter_notebook_config.py"*** under hidden directorary .jupyter which locates home.
Get password:
from notebook.auth import passwd
passwd()
or you can set as the following method:
jupyter notebook password
This command will produce a json configuration file under .jupyter, called jupyter_notebook_config.json . Parameters can be changed if possible.It’s better to reference to https://jupyter-notebook.readthedocs.io/en/stable/config.html
c.NotebookApp.ip=‘*’ // 任意IP可以访问 c.NotebookApp.password =u’sha1:ce…复制的那个密码串’ //passwd() 生成的密码
c.NotebookApp.open_browser = False
c.NotebookApp.port =8888 #可以自行指定服务器未使用的端口 c.NotebookApp.allow_remote_access = True
c.NotebookApp.notebook_dir = ‘/public/group/user/.jupyter/’ // work directory of jupyter and code files will be saved at the directory.
3.2 主题配置
pip install jupyterthemes
jt -l // list theme
jt -t chesterish // setup theme
Note: After installing, reboot Jupyter.
4. 远程访问
启动: nohup jupyter notebook >~/jupyter.log 2>&1 &
or /usr/local/bin/jupyter-notebook --allow-root --port=8890 --ip 192.xxx
// Need root authority
http://ip:8888 # //浏览器中输入 设置的ip和端口即可访问
5. jupyterhub中灵活使用不同版本的python、R或者其他语言
Used conda to install python or R plantform stepwisely, for example installing pyhthon 3.9:
conda create -n python3.9 python=3.9 // create virtual environment
conda activate python3.9 // activate environment
python3 -m pip install ipykernel // install ipykernel. note: Other packages should be installed as this way.
python -m ipykernel install --name py39 --user // register into jupyterhub, name will by shew in brower.
Another example installing R:
conda create -n R4
conda create -n R4
conda install python=3.6 // install python again, provide port?
python3 -m pip install ipykernel
conda install -c conda-forge r-base=4.2.0
R
options("repos" = c(CRAN="https://mirrors.tuna.tsinghua.edu.cn/CRAN/"))
install.packages('IRkernel')
IRkernel::installspec(name = 'ir4.0test', displayname = 'R4.2')
6. jupyterhub使用
Interface was divided different cells. Impement codes in cell using ctr+ enter
reference: https://www.tutorialspoint.com/jupyter/jupyter_notebook_types_of_cells.htm