Jupyter的搭建

1. 安装Anaconda

安装Anaconda吧,它的Python工具比较齐

wget -c https://repo.anaconda.com/archive/Anaconda3-2019.10-Linux-x86_64.sh
bash Anaconda3-5.2.0-Linux-x86_64.sh

2. 安装并配置Jupyter

2.1 安装jupyter

因为Anaconda中jupyter默认就已经安装了,所以这里我们不需要安装,但如果python用的不是Anaconda,则需要安装jupyter,安装过程如下

python3 -m pip install --upgrade pip
python3 -m pip install jupyter

2.2 配置jupyter

2.2.1 生成jupyter配置文件

jupyter notebook --generate-config --allow-root

2.2.2 为jupyter设置密码

在终端中键入python回车后输入如下代码后回车

from notebook.auth import passwd 
passwd()

回车后会显示一串sha1加密的密码,后面会用到这个密码,需要保存

2.2.3 修改jupyter配置文件

jupyter配置文件位置:

  • vim /root/.jupyter/jupyter_notebook_config.py

c.NotebookApp.allow_password_change = False
c.NotebookApp.allow_remote_access = True
c.NotebookApp.allow_root = True
c.NotebookApp.ip = '*'
c.NotebookApp.notebook_dir = '这里填文档保存的路径'
c.NotebookApp.open_browser = False
c.NotebookApp.password = '这里填刚刚生成的密码'

3. 启动Jupyter

3.1 启动

提醒:在启动之前要设置防火墙规则对其放行,这里不建议彻底关闭防火墙,但是SELinux建议将其关闭

nohup jupyter notebook --allow-root >/root/jupyter.logfile 2>&1 &

3.2 确认

如果8888端口正在监听,则表示jupyter启动成功

ss -tnlp | grep 8888

4. 访问Jupyter

浏览器访问:http://IP地址:8888 

原文地址:https://www.cnblogs.com/hgzero/p/12805292.html