在服务器开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
相关推荐
程序设计实验室17 小时前
2025年了,在 Django 之外,Python Web 框架还能怎么选?
python
倔强青铜三19 小时前
苦练Python第46天:文件写入与上下文管理器
人工智能·python·面试
用户2519162427111 天前
Python之语言特点
python
刘立军1 天前
使用pyHugeGraph查询HugeGraph图数据
python·graphql
数据智能老司机1 天前
精通 Python 设计模式——创建型设计模式
python·设计模式·架构
数据智能老司机1 天前
精通 Python 设计模式——SOLID 原则
python·设计模式·架构
c8i1 天前
django中的FBV 和 CBV
python·django
c8i1 天前
python中的闭包和装饰器
python
这里有鱼汤1 天前
小白必看:QMT里的miniQMT入门教程
后端·python
TF男孩2 天前
ARQ:一款低成本的消息队列,实现每秒万级吞吐
后端·python·消息队列