服务器安装jupyter服务


前置需要安装python,pip

安装jupyter

pip install jupyterlab

创建配置文化

itaken@itaken:~$ jupyter notebook --generate-config
Writing default config to: /path/to/user/.jupyter/jupyter_notebook_config.py

或者可以在用户目录下的.jupyter目录下创建jupyter_notebook_config.py文件.

创建密码

itaken@itaken:~$ jupyter-notebook password
Enter password:
Verify password:
[NotebookPasswordApp] Wrote hashed password to /path/to/user/.jupyter/jupyter_notebook_config.json

或者使用ipython创建密码

itaken@itaken:~$ ipython
Python 3.8.6 (default, Jan  4 2021, 16:11:49)
Type 'copyright', 'credits' or 'license' for more information
IPython 7.23.0 -- An enhanced Interactive Python. Type '?' for help.

In [1]: from notebook.auth import passwd

In [2]: passwd()
Enter password:
Verify password:
Out[2]: 'argon2:$argon2id$v=19$m=10240,t=10,p=8$stXXAnzQIh628xxxJqJ2nw$eseO52wGcwUVH26zvAndxx'

In [3]: exit

查看配置文件jupyter_notebook_config.json

itaken@itaken:~$ cat /path/to/user/.jupyter/jupyter_notebook_config.json
{
  "NotebookApp": {
    "password": "argon2:$argon2id$v=19$m=10240,t=10,p=8$stXXAnzQIh628xxxJqJ2nw$eseO52wGcwUVH26zvAndxx"
  }
}

添加其他配置(可选)

{
    "NotebookApp": {
        "ip": "*",
        "port": 6688,
        "notebook_dir": "/path/to/jupyter/jupyter-data",
        "open_browser": false,
        "allow_remote_access": true,
        "password": "argon2:$argon2id$v=19$m=10240,t=10,p=8$stXXAnzQIh628xxxJqJ2nw$eseO52wGcwUVH26zvAndxx"
    }
}

启动

itaken@itaken:~$ jupyter notebook
[W 21:12:54.103 NotebookApp] WARNING: The notebook server is listening on all IP addresses and not using encryption. This is not recommended.
[I 21:12:54.112 NotebookApp] Serving notebooks from local directory: /path/to/jupyter/jupyter-data
[I 21:12:54.112 NotebookApp] Jupyter Notebook 6.3.0 is running at:
[I 21:12:54.112 NotebookApp] http://127.0.0.1:6688/
[I 21:12:54.112 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
^C[I 21:30:25.738 NotebookApp] interrupted
Serving notebooks from local directory: /path/to/jupyter/jupyter-data
0 active kernels
Jupyter Notebook 6.3.0 is running at:
http://127.0.0.1:6688/
...

后台执行可以使用如下命令

nohup jupyter notebook --notebook-dir="/path/to/jupyter/jupyter-data" > jupyter.log 2>&1 &

访问http://127.0.0.1:6688/

输入之前设置的密码,开始jupyter之旅吧


参考文档


Author: Itaken
Reprint policy: All articles in this blog are used except for special statements CC BY 4.0 reprint polocy. If reproduced, please indicate source Itaken !
  TOC目录