
Jupyter 的安装与远程配置
📦 安装 Jupyter
基础安装(Conda 环境)
conda install jupyter
添加内核到 Jupyter
激活你要加到 Jupyter 里面的本地环境
conda activate [env]
安装 ipykernel
conda install ipykernel
将本地环境注入 Jupyter
python -m ipykernel install --user --name [环境名称] --display-name [在jupyter上显示的环境名称]
验证安装
jupyter kernelspec list # 查看已注册内核
输出示例:
Available kernels:
pydata /Users/you/Library/Jupyter/kernels/pydata
python3 /usr/local/share/jupyter/kernels/python3
🌐远程访问
生成加密密码
from notebook.auth import passwd
passwd() # 执行后输入并确认密码
输出示例(保存 sha1 哈希):
'sha1:67c9e60bb8b6:9ffede0825894254b2e042ea597d771089e11aed'
生成配置文件
jupyter notebook --generate-config
编辑配置文件
配置文件位置:~/.jupyter/jupyter_notebook_config.py
# 允许远程访问
c.ServerApp.allow_remote_access = True
# 监听所有IP
c.ServerApp.ip = '0.0.0.0'
# 禁用自动打开浏览器
c.ServerApp.open_browser = False
# 设置访问端口(默认8888)
c.ServerApp.port = 8888
# 设置密码(使用生成的sha1)
c.ServerApp.password = 'sha1:67c9e60bb8b6:...'
# 禁止使用token登录(启用密码后)
c.ServerApp.token = ''
# 设置SSL加密(可选但推荐)
c.ServerApp.certfile = '/path/to/your/cert.pem'
c.ServerApp.keyfile = '/path/to/your/key.pem'
本文是原创文章,采用 CC BY-NC-ND 4.0 协议,完整转载请注明来自 UrAsh
评论
匿名评论
隐私政策
你无需删除空行,直接评论以获取最佳展示效果