网络编程
位置:首页>> 网络编程>> Python编程>> Ubuntu安装Jupyter Notebook教程

Ubuntu安装Jupyter Notebook教程

作者:faramita2016  发布时间:2021-03-12 03:14:58 

标签:Ubuntu,Jupyter,Notebook

一.Jupyter介绍

Jupyter Notebook是一个交互式笔记本,支持运行40多种编程语言。Jupyter Notebook 的本质是一个 Web 应用程序,便于创建和共享文学化程序文档,支持实时代码,数学方程,可视化和 markdown。用途包括:数据清理和转换,数值模拟,统计建模,机器学习等等。 

二.安装步骤

环境:Docker(17.04.0-ce)、镜像Ubuntu(16.04.3)

1. 更新软件列表


root@787c084a44e4:~# apt-get update

2. 安装pip


root@787c084a44e4:~# apt-get install -y python3-pip

3. 更新pip(-m参数将库中的pip模块作为脚本运行,--upgrade更新pip模块)


root@787c084a44e4:~# python3 -m pip install --upgrade pip

4. 使用pip安装Jupyter


root@787c084a44e4:~# python3 -m pip install jupyter

5. 使用pip安装python绘图库(示例需要使用)


root@787c084a44e4:~# python3 -m pip install matplotlib

6. 创建Jupyter默认配置文件


root@787c084a44e4:~# jupyter notebook --generate-config

7. 生成SHA1加密的密钥,保存密钥,如'sha1:XXXXXX'


root@787c084a44e4:~# ipython

输入


from notebook.auth import passwd
passwd()

8. 设置密钥,修改配置文件


root@787c084a44e4:~# vim .jupyter/jupyter_notebook_config.py

在文件末尾增加


c.NotebookApp.password = u'sha1:XXXXXX'

9. 运行Jupyter(--ip指定ip,--no-browser不打开浏览器,--allow-root允许root运行)


root@787c084a44e4:~# jupyter notebook --ip=0.0.0.0 --no-browser --allow-root

10. 打开浏览器输入http://172.17.0.2:8888/

Ubuntu安装Jupyter Notebook教程

三.Jupyter示例

新建python3笔记


%matplotlib inline

import numpy as np
import matplotlib.pyplot as plt

x = np.arange(9)
y = np.sin(x)
plt.plot(x, y)
plt.show()

运行结果

Ubuntu安装Jupyter Notebook教程

四.异常情况

1. locale.Error: unsupported locale setting异常

Ubuntu安装Jupyter Notebook教程

设置locale,使用默认本地化设置
root@787c084a44e4:~# export LC_ALL=C

2. OSError: [Errno 99] Cannot assign requested address异常

Ubuntu安装Jupyter Notebook教程

运行Jupyter时增加--ip=0.0.0.0参数
root@787c084a44e4:~# jupyter notebook --ip=0.0.0.0 --no-browser --allow-root

3. ImportError: No module named 'matplotlib'异常

Ubuntu安装Jupyter Notebook教程

安装matplotlib库


root@787c084a44e4:~# python3 -m pip install matplotlib

来源:http://www.cnblogs.com/faramita2016/p/7512471.html

0
投稿

猜你喜欢

手机版 网络编程 asp之家 www.aspxhome.com