温馨提示×

debian如何配置jupyter

小樊
46
2026-10-08 01:37:23
栏目: 智能运维

在 Debian 上配置 Jupyter(通常指 Jupyter Notebook 或 JupyterLab)一般包含安装、生成配置、设置密码/远程访问几个步骤。下面以 Debian 11/12 为例说明。


一、安装 Python 与 pip

sudo apt update
sudo apt install -y python3 python3-pip python3-venv

二、安装 Jupyter

方式 1:系统级安装(简单)

pip3 install --break-system-packages jupyter

方式 2:虚拟环境(推荐)

python3 -m venv jupyter_env
source jupyter_env/bin/activate
pip install jupyter

三、生成 Jupyter 配置文件

jupyter notebook --generate-config

配置文件路径:

~/.jupyter/jupyter_notebook_config.py

四、设置登录密码(推荐)

jupyter notebook password

输入密码后,会生成:

~/.jupyter/jupyter_server_config.json

五、配置远程访问(如服务器)

编辑配置文件:

nano ~/.jupyter/jupyter_notebook_config.py

添加或修改:

c.ServerApp.ip = '0.0.0.0'
c.ServerApp.open_browser = False
c.ServerApp.port = 8888
c.ServerApp.allow_remote_access = True

旧版本可能是 c.NotebookApp.*


六、启动 Jupyter

jupyter notebook

或后台运行:

nohup jupyter notebook > jupyter.log 2>&1 &

浏览器访问:

http://服务器IP:8888

七、(可选)使用 JupyterLab

pip install jupyterlab
jupyter lab

八、(可选)用 systemd 管理

示例 jupyter.service:

[Unit]
Description=Jupyter Notebook

[Service]
Type=simple
User=你的用户名
WorkingDirectory=/home/你的用户名
ExecStart=/usr/local/bin/jupyter notebook
Restart=on-failure

[Install]
WantedBy=multi-user.target
sudo systemctl enable --now jupyter

如果你告诉我:

  • 是 本地还是服务器
  • 用 Notebook 还是 Lab
  • 是否 root 用户

我可以给你更精确的配置方案。

0 踩