jupyter的安装与基本使用

jupyter官网:

https://jupyter.org/

jupyter官方搭建指南:

https://jupyter.org/install

jupyter官方文档:

https://jupyter-notebook.readthedocs.io/en/stable/notebook.html

 

jupyter的安装与基本使用

1. 安装前提

安装Jupyter Notebook的前提是需要安装了Python(3.3版本及以上,或2.7版本)。

 

2.使用pip命令安装

首先进入dos,

pip install --upgrade pip              ##升级pip

pip install jupyter                         ##安装jupyter

jupyter notebook --help               ##查看命令指南

jupyter notebook -h

 

3.修改配置jupyter

jupyter notebook --generate-config                                          ##获取配置文件路径

C:\Users\Heber\.jupyter\jupyter_notebook_config.py

##如果按“y”,则完成覆盖,那么之前所做的修改都将失效;如果只是为了查询路径,输入“N”。

##url修改(默认即可)

## The default URL to redirect to from `/`

#c.NotebookApp.default_url = '/tree'

##启动的路径的修改(默认情况时,cd到什么目录下启动,jupyter页面默认即在什么目录下)

## The directory to use for notebooks and kernels.

#c.NotebookApp.notebook_dir = ''

##可修改为自己需要地址:

c.NotebookApp.notebook_dir = 'C:/Users/Heber/Desktop/jupyter'

 

4.启动jupyter

cd C:\Users\Heber\Desktop\jupyter                  ##进入提前创建好的文件夹

jupyter notebook                                                ##启动jupyter

jupyter notebook --port 8889                             ##指定端口启动(默认端口8888)

jupyter notebook --no-browser                          ##不打开浏览器方式启动

 

5.使用jupyter

在浏览器打开的jupyter中,点击new->Python3新建py执行文件
注意:

此时可能出现web页面的jupyter出现重启等待模式,并且dos下出现以下报错:

File "c:\users\heber\appdata\local\programs\python\python36-32\lib\site-packages\prompt_toolkit\eventloop\async_generator.py", line 5, in <module>

from typing import AsyncGenerator, Callable, Iterable, TypeVar, Union

ImportError: cannot import name 'AsyncGenerator'

解决:

出现报错的原因是可以在pycharm中使用的模块包版本在jupyter上却不能匹配使用。

最开始进行卸载重新安装ipython,prompt_toolkit模块,发现安装的版本还是不行。

pip uninstall -y ipython prompt_toolkit

pip install ipython prompt_toolk

在更新降低prompt-toolkit模块的版本之后,报错解决。

pip show prompt-toolkit

pip install prompt-toolkit==2.0.10

 

6.jupyter操作指南

View:   用于修改notebook的界面

Cell: 用于单元格的运行等相关操作

Kernel: 用于内核的相关操作

Widget: 常用工具的相关操作

点击上方Untitled,即可修改文件名

输入代码,点击运行或者 shift+enter 即可返回执行结果;

Edit-->拆分合并单元格

Cell-->Cell Type;修改单元格格式

这个标题以一个#开头表示一级标题,两个#表示二级标题,以此类推。

在#后方输入标题并且运行即可添加标题,提高代码的可读性。

File-->Rename重命名文件

 

##执行DOS(shell)命令

##在命令前加上!,即可切换使用dos下的命令

##给Jupyter换主题

##在dos下:

pip install jupyterthemes                  ##安装主题模块

jt -l                                                   ##加载可用主题列表

jt -t chesterish                                  ##改成chesterish主题

jt -r                                                   ##切换为最开始的主题

##同样也能在python下的单元格中,执行之后刷新jupyter页面

 

 

 

 

 

 

 

  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值