gpt4 book ai didi

ubuntu - 在 Ubuntu 上启动时运行 Jupyter-notebook

转载 作者:太空宇宙 更新时间:2023-11-03 16:56:59 24 4
gpt4 key购买 nike

我有一个安装了 anaconda 的 Ubuntu 16.04 虚拟机,我希望它在启动时使用正确的配置文件(IP 地址、端口、密码...)启动 Jupyter-notebook

这个配置在/home/user/.jupyter/jupyter_notebook_config.py中指定

当我以 user 身份登录并位于主目录 (/home/user/) 时,它会启动正确的配置文件。

但是在使用命令的时候

jupyter-notebook

在使用 rc.local 或使用 crontab 启动期间,它不会加载我的配置文件,并且没有正确的运行目录。

最佳答案

非常相似的问答:How to start ipython notebook server at boot as daemon

您可以将以下行添加到您的 /etc/rc.local文件

su <username> -c "jupyter notebook --config=/location/of/your/config/file/.jupyter/jupyter_notebook_config.py --no-browser --notebook-dir=/location/of/yournotebooks" &

例如

su simon -c "jupyter notebook --config=/home/simon/.jupyter/jupyter_notebook_config.py --no-browser --notebook-dir=/home/simon/notebooks" &

su <username> -c确保笔记本不是以 root 身份执行,而是使用指定的用户帐户执行。``

--config--notebook-dir指定配置文件和笔记本文件夹的位置 ( http://jupyter-notebook.readthedocs.io/en/latest/config.html )


对于使用 systemd 的系统(Ubuntu 16 及更高版本)以下方法也有效:

  • /etc/systemd/system/ 中创建一个服务文件,例如jupyter.service使用以下内容(将 YourUserName 替换为您的用户名)

    [Unit]
    After=network.service

    [Service]
    ExecStart=jupyter notebook
    User=YourUserName

    [Install]
    WantedBy=default.target
  • 使用 sudo systemctl enable jupyter.service 启用服务

  • 使用 sudo systemctl start jupyter.service 启动服务

您应该为您的 Jupyter 服务器设置一个密码,因为您将无权访问 token 。

关于ubuntu - 在 Ubuntu 上启动时运行 Jupyter-notebook,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44231789/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com