1. 安装 Jupyter
使用 pip 安装 jupyter 包
$ pip install jupyter
2. 修改配置文件
2.1 将 Jupyter 的配置文件写到家目录下
进入到 pip 可执行文件的所在文件夹下,生成 jupyter 的配置文件,配置文件会生成到家目录的 .jupyter
文件夹下:
$ jupyter-notebook --generate-config
Writing default config to: /home/my_user/.jupyter/jupyter_notebook_config.py
2.2 配置 Jupyter 的密码
创建 get_passwd.py
文件,并在其中添加如下内容:
$ vim get_passwd.py
from notebook.auth import passwd
pwd = passwd()
print(pwd)
添加完成后执行这个脚本:
$ python get_passwd.py
设置密码后,会打印一个密码字符串,将这个字符串存储下来。
修改配置文件,在任意位置添加如下内容:
$ vim jupyter_notebook_config.py
c.NotebookApp.ip = '*' # 允许任何 ip 去访问 Jupyter Notebook
c.NotebookApp.open_browser = False # 不在 Linux 下打开浏览器
c.NotebookApp.port = 8888 # 指定 Jupyter 默认的 8888 端口
c.NotebookApp.allow_remote_access = True # 允许远程控制
c.NotebookApp.notebook_dir = u'路径' # 设置开发 Jupyter Notebook 时打开的路径
c.NotebookApp.password = u'xxxxxxxxxx' # 刚才存储的密码字符串
3. 系统配置
如果开启的防火墙,则需要开启 Jupyter 的默认运行端口:
$ firewall-cmd --zone=public --add-port=8888/tcp --permanent # 添加 Jupyter 的默认运行端口
$ firewall-cmd --reload # 重新载入配置
4. 启动 Jupyter
$ nohup jupyter-notebook >> /home/txjiang/.jupyter/jupyter.log 2>&1 &
- 安装 Nbextensions 扩展包
$ pip install jupyter_contrib_nbextensions
$ jupyter contrib nbextension install --user
$ jupyter nbextension enable codefolding/main