配置Jupyterlab网页IDE

本文详细介绍在无桌面环境的Ubuntu服务器下配置Jupyterlab服务的过程,包括安装、配置、生成配置文件、设置开机启动等步骤,实现远程访问。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Jupyterlab是JupyterNotebook的升级版本,功能更强大,更人性化。下面介绍如何在无桌面环境的ubuntu服务器下配置jupyterlab服务,实现开机启动jupyterlab服务。

1.首先安装jupyter

#有conda虚拟环境的用户需要先激活虚拟环境:conda activate envname
pip install jupyterlab  

2.生成配置文件

jupyter-lab --generate-config #生成配置文件

3.修改部分参数

vim ~/.jupyter/jupyter_notebook_config.py 

c.NotebookApp.default_url = '/lab' #"/lab"启动Jupyterlab, “/tree”则启动JupyterNotebook

c.NotebookApp.ip = '*' # 允许所有IP访问,“localhost” 则只允许本机访问

c.NotebookApp.notebook_dir = '/home/test/pypro'  #启动后的根目录

c.NotebookApp.open_browser = False #启动后不打开浏览器

## Hashed password to use for web authentication.
#  
#  To generate, type in a python/IPython shell:
#  
#    from notebook.auth import passwd; passwd()
#  
#  The string should be of the form type:salt:hashed-password.                  
#c.NotebookApp.password = ''
c.NotebookApp.password = ''  #预设的密码,通过上面的命令设置

## The port the notebook server will listen on.                                 
c.NotebookApp.port = 8888  #默认的端口,当主机运行多个jupyterlab时要确保端口不被占用.不能和其它的jupyterlab的端口相同.

4.写一个 jupyterlab.service 文件实现开机启动

#在/lib/systemd/system 目录下新建 jupyterlab.service 文件,内容如下

[Unit]                                                                          
Description=Jupyter Notebook
After=network.target

[Service]
Type=simple
PIDFile=/home/test/.jupyter/jupyter.pid
ExecStart=/opt/anaconda3/bin/jupyter-lab --config=/home/test/.jupyter/jupyter_notebook_config.py
User=test
Group=test
WorkingDirectory=/pypro
Restart=always
RestartSec=10

[Install]
WantedBy=multi-user.target

将上面的 test,替换为自己的用户名,WorkingDirectory替换为自己的项目路径

5.启动jupyterlab,添加开机启动项。

systemctl start jupyterlab.service  #启动jupyterlab
systemctl enable jupyterlab.service   #添加到开机服务中

完成后即可实现其他主机访问 本机ip:8888 来远程使用Jupyterlab

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值