Jupyter notebook用法

参考官网文档:https://jupyter-notebook.readthedocs.io/en/stable/public_server.html

0.介绍jupyter notebook

(此前被称为 IPython notebook)是一个交互式笔记本,支持运行 40 多种编程语言。

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

他的一个很大优点就是可以把代码、运行结果保存在一个notebook中,这对于学习算法比较重要,因为以后看代码的时候,可以很明确代码运行结果(尤其是在图像处理方面)。

1.安装jupyter notebook

检查是否有安装jupyter notebook,终端输入jupyter notebook,如果报错就是没有啦,那么就要用下面命令安装。

$sudo pip install pyzmq
$sudo pip install tornado
$sudo pip install jinja2
$sudo pip install jsonschema
$sudo pip install jupyter

 

2.生成配置文件

$jupyter notebook --generate-config

启动

$jupyter notebook

生成密钥,密码为admin

3.修改默认配置文件

$vim ~/.jupyter/jupyter_notebook_config.py

进行如下修改(这里可以自行配置):

c.NotebookApp.ip='*'
c.NotebookApp.password = u'sha1:784e14cad32b:1d768f3613ae1a8ff7d74ca34b741591d6656767'
c.NotebookApp.open_browser = False
c.NotebookApp.port =8888 #随便指定一个端口
c.IPKernelApp.pylab = 'inline'

4.启动Jupter notebook

$jupyter notebook

或启动Jupter notebook并指定端口

$jupyter notebook --no-browser --port=8889

5.访问WEB页面

http://localhost:9999/

6.create a new notebook with 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()

7.安装python库

$ pip install matplotlib

8.笔记效果

%matplotlib inline
import matplotlib.pyplot as plt
import numpy as np

x = np.arange(20)
y = x**2

plt.plot(x, y)

 

posted @ 2018-03-30 11:27  amoyzhu  阅读(432)  评论(0编辑  收藏  举报