Jupyter Notebook(此前被称为 IPython notebook)是一个交互式笔记本,支持运行 40 多种编程语言。在本文中,我们将介绍 Jupyter notebook 的主要特性,以及为什么对于希望编写漂亮的交互式文档的人来说是一个强大工具。
在开始使用 notebook 之前,我们先需要安装该库。你可以在 Jupyter 官网上找到完整的步骤。
译者注:其实只要
pip install jupyter
就可以了
jupyter notebook
运行上面的命令之后,你将看到类似下面这样的输出:
[I 20:06:36.367 NotebookApp] Writing notebook server cookie secret to /run/user/1000/jupyter/notebook_cookie_secret [I 20:06:36.813 NotebookApp] Serving notebooks from local directory: /home/your_username [I 20:06:36.813 NotebookApp] 0 active kernels [I 20:06:36.813 NotebookApp] The IPython Notebook is running at: http://localhost:8888/ [I 20:06:36.813 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
Running as root is not recommended. Use --allow-root to bypass
首先输入,查看配置文件位置
[as-pc as]# jupyter notebook --generate-config --allow-root
Overwrite /root/.jupyter/jupyter_notebook_config.py with default config? [y/N]y
Writing default config to: /root/.jupyter/jupyter_notebook_config.py
接下来打开配置文件
gedit /root/.jupyter/jupyter_notebook_config.py
1
找到这一行
#c.NotebookApp.allow_root = False
去掉#,并修改成True即可解决root权限运行的问题
c.NotebookApp.allow_root =True
保存,重新运行程序
jupyter notebook
设置访问密码
打开 ipython 输入
from notebook.auth import passwd
passwd()
然后根据提示输入2次密码
Enter password: ········
Verify password: ········
然后复制 ‘sha1:f5643****************************’ 粘贴至配置文件(记得去掉 #)