python - 在 Linux 中启动 Jupyterlab
问题描述
我已经使用anaconda在我的 Ubuntu 20.04 机器上安装了JupyterLab。
我想在启动时启动 Jupyterlab。
我可以通过执行以下操作让 Jupyterlab 在启动时运行:
创建文件/etc/systemd/system/jupyter.service
[Unit]
Description=Jupyter Lab
[Service]
Type=simple
PIDFile=/run/jupyter.pid
ExecStart=/home/USERNAME/anaconda3/envs/jupyterlab/bin/jupyter lab
User=USERNAME
WorkingDirectory=/home/USERNAME/Documents
Restart=always
RestartSec=10
[Install]
WantedBy=multi-user.target
替换用户名。
然后运行以下命令:
sudo systemctl daemon-reload
sudo systemctl enable jupyter.service
sudo systemctl restart jupyter.service
sudo systemctl status jupyter.service
但是,在 jupyter 笔记本中,如果我运行命令
!python
我得到了我的系统 python,而不是我的 conda 环境 python。
如何在启动时启动 jupyterlab,并且仍然可以!commands
按预期工作?
解决方案
感谢@krassowski 将ExecStart
线路更改为:
ExecStart=/bin/bash -i -c "conda activate jupyterlab;jupyter lab"
解决了我的问题。
IE:
[Unit]
Description=Jupyter Lab
[Service]
Type=simple
PIDFile=/run/jupyter.pid
ExecStart=/bin/bash -i -c "conda activate jupyterlab;jupyter lab"
User=USERNAME
WorkingDirectory=/home/USERNAME/Documents
Restart=always
RestartSec=10
[Install]
WantedBy=multi-user.target
推荐阅读
- netbeans - 输入新示例的属性值以使用 Netbeans 将其标签预测为 RapidMiner Process
- java - .hasNext() 和 .next() 导致无限循环
- tensorflow - 在 keras 的 model.fit 中随机播放
- python - TensorFlow:SparseSoftmaxCrossEntropyWithLogits 错误?
- memory - CUDA - 固定内存与可分页内存的权衡
- javascript - .indexOf javascript中的多行
- php - 根据 WooCommerce 中的产品或类别隐藏特定的运输选项
- r - 在 R 中使用 format() 格式化数字向量
- python - CrawlSpider 不工作
- json - 播放:scala Json.format 日期