【实用工具】Linux安装JupyterLab
引言
JupyterLab相对于jupyter notebook来说是用过之后就再也不想换回去的存在。Linux安装jupyter lab的过程如下
安装方法
pip安装
1
2pip install jupyterlab # 安装jupyter
pip install jupyterlab-language-pack-zh-CN # 安装汉化包,需要自己选择语言生成jupyterlab配置文件,路径为
~/.jupyter/jupyter_lab_config.py1
jupyter lab --generate-config
创建并确认密码,会生成
~/.jupyter/jupyter_server_config.json1
jupyter lab password
查看文件内容,如下图,复制password后的一串字符
1
less ~/.jupyter/jupyter_server_config.json
修改配置文件
1
vim ~/.jupyter/jupyter_lab_config.py
添加以下内容
1
2
3
4
5
6
7
8c.ServerApp.allow_remote_access = True # 允许远程访问
c.ServerApp.allow_root = True # 允许root运行
c.ServerApp.notebook_dir = u'工作文件夹' # 设置工作目录,默认为用户家目录
c.ServerApp.ip = '*' # 监听地址
c.ServerApp.port = 8888 # 运行端口,默认8888
c.ServerApp.password = '刚复制的字符串' # 密码
c.ServerApp.open_browser = False # 不打开浏览器
c.NotebookApp.terminado_settings = {'shell_command': ['/bin/bash']} # 设置启动时的shell启动jupyter lab
1
nohup python3 -m jupyterlab --allow-root > ~/.jupyter/jupyter.log 2>&1 &
此处利用nohup命令让jupyterlab在后台执行,并输出日志到~/.jupyter/jupyter.log文件中,该串代码运行后会输出jupyterlab的进程号,通过进程号,可以使用kill -9 进程号来终止项目。
在浏览器输入
IP:端口号即可进行访问。在设置-语言中切换中文显示设置开机自启动
1
2
3crontab -e
@reboot nohup python3 -m jupyterlab --allow-root > ~/.jupyter/jupyter.log 2>&1 &
参考
https://blog.csdn.net/qq_29183811/article/details/126631328
https://www.jianshu.com/p/38bd9c5e7c8d
https://stackoverflow.com/questions/33467098/how-can-the-terminal-in-jupyter-automatically-run-bash-instead-of-sh
评论