在服务器开jupyter notebook server

参考

1、安装notebook

bash 复制代码
pip install notebook

2、生成配置文件

bash 复制代码
jupyter notebook --generate-config

生成的配置文件,在linux下的路径一般是"/home/USERNAME/.jupyter/jupyter_notebook_config.py"

3、配置密码

bash 复制代码
jupyter notebook password

Enter password:  ****
Verify password: ****
[NotebookPasswordApp] Wrote hashed password to /Users/you/.jupyter/jupyter_notebook_config.json

4、编辑配置文件

bash 复制代码
vim ~/.jupyter/jupyter_notebook_config.py


# 在 jupyter_notebook_config.py 文件中添加以下配置
# Set ip to '*' to bind on all interfaces (ips) for the public server
c.NotebookApp.ip = '*'
c.NotebookApp.open_browser = False
# It is a good idea to set a known, fixed port for server access
c.NotebookApp.port = 8888
c.NotebookApp.notebook_dir = '/root/jupyter_projects' #这里是设置Jupyter的根目录
c.NotebookApp.allow_root = True # 为了安全,Jupyter默认不允许以root权限启动jupyter

5、启动notebook后台运行

bash 复制代码
nohup jupyter notebook --port=12345 --no-browser > logs/jupyter_notebook.log 2>&1 &

上面的指令也可以添加上 --allow-root

6、在本地浏览器访问

在浏览器中输入 http://ip:12345

7、查看端口是不是被占用

bash 复制代码
# 查看端口12345是不是被其他进程占用了
netstat -lnp | grep 12345

# 也可以用下面的方式查看 端口12345 是不是被占用了
ps -ef | grep 12345
相关推荐
eqwaak09 分钟前
数据预处理与可视化流水线:Pandas Profiling + Altair 实战指南
开发语言·python·信息可视化·数据挖掘·数据分析·pandas
心态特好1 小时前
详解WebSocket及其妙用
java·python·websocket·网络协议
dlraba8022 小时前
用 Python+OpenCV 实现实时文档扫描:从摄像头捕捉到透视矫正全流程
开发语言·python·opencv
小熊出擊2 小时前
【pytest】fixture 内省(Introspection)测试上下文
python·单元测试·pytest
njsgcs2 小时前
sse mcp flask 开放mcp服务到内网
后端·python·flask·sse·mcp
一人の梅雨2 小时前
1688 店铺商品全量采集与智能分析:从接口调用到供应链数据挖掘
开发语言·python·php
Terio_my3 小时前
Python制作12306查票工具:从零构建铁路购票信息查询系统
开发语言·python·microsoft
万粉变现经纪人3 小时前
如何解决 pip install -r requirements.txt 约束文件 constraints.txt 仅允许固定版本(未锁定报错)问题
开发语言·python·r语言·django·beautifulsoup·pandas·pip
站大爷IP3 小时前
Python定时任务实战:APScheduler从入门到精通
python
Fairy_sevenseven4 小时前
[1]python爬虫入门,爬取豆瓣电影top250实践
开发语言·爬虫·python