在 Debian 上配置 Jupyter(通常指 Jupyter Notebook 或 JupyterLab)一般包含安装、生成配置、设置密码/远程访问几个步骤。下面以 Debian 11/12 为例说明。
sudo apt update
sudo apt install -y python3 python3-pip python3-venv
pip3 install --break-system-packages jupyter
python3 -m venv jupyter_env
source jupyter_env/bin/activate
pip install 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 notebook
或后台运行:
nohup jupyter notebook > jupyter.log 2>&1 &
浏览器访问:
http://服务器IP:8888
pip install jupyterlab
jupyter lab
示例 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
如果你告诉我:
我可以给你更精确的配置方案。