JupyterNotebook–基础–02–安装
1、安装
pip3 install jupyter
pip3 install ipython
2、生成配置文件
用于后面写入ip,端口号,密码等
jupyter notebook --generate-config
3、修改配置文件
3.1、获取密码
# 启动ipython,配置密码(注意不是python)
ipython
In [1]: from notebook.auth import passwd # 导入包
In [2]: passwd() # 调用包
Enter password: # 输入密码,用于后面登陆jupyter notebook
Verify password: # 确认密码
Out[2]: 'sha1:ce23d945972f:111111' #这段是密钥,复制下来等会用
exit() #退出
3.2、编辑配置文件
vim /root/.jupyter/jupyter_notebook_config.py
内容
c.NotebookApp.ip = '*' #允许任何ip去访问我们的jupyter notebook
c.NotebookApp.password = u'sha1:ce23d945972f:111111' #u后面加上你复制的密钥
c.NotebookApp.open_browser = False #因为是在linux,就不让他打开浏览器了
c.NotebookApp.port = 8888 #随便指定一个端口,如果这个端口被占用,jupyter会加1重新找端口,直到找到为止
c.NotebookApp.allow_remote_access = True #允许远程控制
c.NotebookApp.notebook_dir = u'/app/jupyter_notebook/data' # 设置你打开jupyter notebook的时候想显示的位置,可以设置成经常使用的路径
4、启动
# 创建目录
mkdir -p /app/jupyter_notebook/{data,log}
cd /app/jupyter_notebook/log/
# 后台启动
nohup jupyter notebook --allow-root > /app/jupyter_notebook/log/jupyter.log 2>&1 &
# 前台启动
# jupyter notebook --allow-root
5、访问
http://192.168.187.200:8888/
密码:1234
6、安装 扩展插件
6.1、安装jupyter_contrib_nbextensions库
python -m pip install jupyter_contrib_nbextensions
6.2、配置 nbextension
jupyter contrib nbextension install --user --skip-running-check
6.3、启动
- 重启 JupyterNotebook
- 选择 Nbextensions,勾选 Table of Contents