配置服务器jupyter notebook

姜智浩 Lv5

前言

本教程是通过我的Linux虚拟机进行教学的,自己租赁或购买的Linux服务器同理,教程是通用的

前置条件

  1. 安装python
  2. 安装pip

这两个安装非常简单,自己从网上查找教程

安装anaconda

从anaconda官网下载相应的版本

anaconda下载地址

进入后选择相应的版本,请注意。文件名中aarch64是arm处理器的版本;X86是inter处理器的版本,根据你处理器型号下载,不要下载错了。

使用wget进行下载

1
wget https://repo.anaconda.com/archive/Anaconda3-2025.06-1-Linux-aarch64.sh

下载好后还可以用ls查看是否下载完成,可以看到,我这里已经下载完成了

1
2
3
4
5
6
7
8
9
10
11
12
13
14
wget https://repo.anaconda.com/archive/Anaconda3-2025.06-1-Linux-aarch64.sh
--2025-11-24 06:01:19-- https://repo.anaconda.com/archive/Anaconda3-2025.06-1-Linux-aarch64.sh
Resolving repo.anaconda.com (repo.anaconda.com)... 104.16.191.158, 104.16.32.241, 2606:4700::6810:bf9e, ...
Connecting to repo.anaconda.com (repo.anaconda.com)|104.16.191.158|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 929680981 (887M) [application/octet-stream]
Saving to: ‘Anaconda3-2025.06-1-Linux-aarch64.sh’

Anaconda3-2025.06-1-Li 100%[==========================>] 886.61M 12.2MB/s in 79s

2025-11-24 06:02:39 (11.3 MB/s) - ‘Anaconda3-2025.06-1-Linux-aarch64.sh’ saved [929680981/929680981]

zhihaojiang@linux-24-10-node5:~$ ls
Anaconda3-2025.06-1-Linux-aarch64.sh

接下来赋予安装包权限

1
chmod +x Anaconda3-2025.06-1-Linux-aarch64.sh

运行安装脚本

1
bash Anaconda3-2025.06-1-Linux-aarch64.sh

运行后如下所示,根据他给的提示,一路yes和回车即可

1
2
3
4
5
6
7
8
zhihaojiang@linux-24-10-node5:~$ bash Anaconda3-2025.06-1-Linux-aarch64.sh

Welcome to Anaconda3 2025.06-1

In order to continue the installation process, please review the license
agreement.
Please, press ENTER to continue
>>>

使配置生效

1
source ~/.bashrc

运行后你会发现你的名称前面会多个“(base)”

1
2
zhihaojiang@linux-24-10-node5:~$ source ~/.bashrc
(base) zhihaojiang@linux-24-10-node5:~$

这个是conda的默认环境

可以查看conda版本

1
2
(base) zhihaojiang@linux-24-10-node5:~$ conda --version
conda 25.5.1

安装Jupyter

运行

1
conda install jupyter

其会显示

1
2
3
4
5
6
7
(base) zhihaojiang@linux-24-10-node5:~$ conda install jupyter
2 channel Terms of Service accepted
Channels:
- defaults
Platform: linux-aarch64
Collecting package metadata (repodata.json): done
Solving environment: done

创建配置

1
jupyter notebook --generate-config

会显示

1
2
(base) zhihaojiang@linux-24-10-node5:~$ jupyter notebook --generate-config
Writing default config to: /home/zhihaojiang/.jupyter/jupyter_notebook_config.py

看见Writing default config to:XXX.py 就说明配置创建了

设置密码

这里的密码一定要设置,因为我们使用是是通过地址加端口使用Jupyter notebook的因此不设置密码是无法使用的

1
jupyter notebook password

其会让你输入两次密码

1
2
3
4
(base) zhihaojiang@linux-24-10-node5:~$ jupyter notebook password
Enter password:
Verify password:
[JupyterPasswordApp] Wrote hashed password to /home/zhihaojiang/.jupyter/jupyter_server_config.json

修改配置文件

1
nano ~/.jupyter/jupyter_notebook_config.py

在文件中添加如下配置

1
2
3
4
5
6
c = get_config()
c.NotebookApp.ip = '0.0.0.0'
c.NotebookApp.port = 8888
c.NotebookApp.open_browser = False
c.NotebookApp.allow_root = True
c.NotebookApp.notebook_dir = '/home/你自己的用户名

我这里端口是8888,若你的这个端口被占用了,可以更换成别的没被占用的端口

启动

运行

1
jupyter notebook

即可启动

若看见如下输出就说明启动成功

1
2
3
4
(base) zhihaojiang@linux-24-10-node5:~$ jupyter notebook
[I 2025-11-24 06:14:22.857 ServerApp] Extension package panel.io.jupyter_server_extension took 0.5411s to import
[I 2025-11-24 06:14:22.858 ServerApp] jupyter_lsp | extension was successfully linked.
[I 2025-11-24 06:14:22.859 ServerApp] jupyter_server_terminals | extension was successfully linked.

进入Jupyter notebook

在浏览器中输入你自己服务器的IP:端口,输入之前设置的密码后就可以开始使用了

关闭服务器中的Jupyter

只要在服务器中输入ctrl+C就可以关闭了
如下看见Shutdown confirmed就安全关闭了

1
2
3
4
5
6
7
8
9
10
^C[I 2025-11-24 06:15:32.461 ServerApp] interrupted
[I 2025-11-24 06:15:32.462 ServerApp] Serving notebooks from local directory: /home/zhihaojiang
0 active kernels
Jupyter Server 2.15.0 is running at:
http://linux-24-10-node5:8888/tree
http://127.0.0.1:8888/tree
Shut down this Jupyter server (y/[n])? y
[C 2025-11-24 06:15:33.784 ServerApp] Shutdown confirmed
[I 2025-11-24 06:15:33.795 ServerApp] Shutting down 6 extensions
(base) zhihaojiang@linux-24-10-node5:~$
  • Title: 配置服务器jupyter notebook
  • Author: 姜智浩
  • Created at : 2025-11-25 11:45:14
  • Updated at : 2025-11-25 21:02:47
  • Link: https://super-213.github.io/zhihaojiang.github.io/2025/11/25/20251125配置服务器jupyter notebook/
  • License: This work is licensed under CC BY-NC-SA 4.0.