jupyter-notebook


一、什么是Jupyter Notebook?

转自:https://zhuanlan.zhihu.com/p/33105153

1. 简介

Jupyter Notebook是基于网页的用于交互计算的应用程序。其可被应用于全过程计算:开发、文档编写、运行代码和展示结果。——Jupyter Notebook官方介绍

简而言之,Jupyter Notebook是以网页的形式打开,可以在网页页面中直接编写代码运行代码,代码的运行结果也会直接在代码块下显示的程序。如在编程过程中需要编写说明文档,可在同一个页面中直接编写,便于作及时的说明和解释。

2. 组成部分

① 网页应用

网页应用即基于网页形式的、结合了编写说明文档、数学公式、交互计算和其他富媒体形式的工具。简言之,网页应用是可以实现各种功能的工具。

② 文档

即Jupyter Notebook中所有交互计算、编写说明文档、数学公式、图片以及其他富媒体形式的输入和输出,都是以文档的形式体现的。

这些文档是保存为后缀名为.ipynbJSON格式文件,不仅便于版本控制,也方便与他人共享。

此外,文档还可以导出为:HTML、LaTeX、PDF等格式。

3. Jupyter Notebook的主要特点

① 编程时具有语法高亮缩进tab补全的功能。

② 可直接通过浏览器运行代码,同时在代码块下方展示运行结果。

③ 以富媒体格式展示计算结果。富媒体格式包括:HTML,LaTeX,PNG,SVG等。

④ 对代码编写说明文档或语句时,支持Markdown语法。

⑤ 支持使用LaTeX编写数学性说明。

二、安装与使用

1、下载jupyter模块

jupyter notebook相当于python解释器的一个模块,因此我们需要先安装一个解释器(前提条件)

然后执行命令安装jupyter模块

pip install jupyter

由于jupyter相当于一个简易的IDE工具,因此他需要下载比较长的一段时间

2、启动jupyter notebook

下载成功后在cmd界面输入命令启动jupyter notebook

jupyter notebook

启动成功后,会在浏览器打开一个界面,界面如下:

image

ps:cmd窗口不要关闭,他相当于开了一个进程,关闭了cmd窗口就等于关闭了这个进程

3、设置工作目录

1.介绍

根据上图,我们可以发现第一次进入这个界面,他会打开一个目录,然后把内部的文件展示在当前页面中

这个目录就是我们cmd界面进去后的目录

image

了解了基本情况后,我们就需要自行设置jupyter notebook的文件存放目录

2.创建文件夹/目录

首先我们选择一个位置创建文件夹,用来当作jupyter的文件目录,比如我的路径如下:

D:\pythonproject\jupyterproject

3.查找jupyter的配置文件路径

一个便捷获取配置文件所在路径的命令:

jupyter notebook --generate-config

ps1:这条命令虽然可以用于查看配置文件所在的路径,但主要用途是是否将这个路径下的配置文件替换默认配置文件。 如果你是第一次查询,那么或许不会出现下图的提示;若文件已经存在或被修改,使用这个命令之后会出现询问“Overwrite /Users/raxxie/.jupyter/jupyter_notebook_config.py with default config? [y/N]”,即“用默认配置文件覆盖此路径下的文件吗?”,如果按“y”,则完成覆盖,那么之前所做的修改都将失效;如果只是为了查询路径,那么一定要输入“N”。

image

ps2:如果你是第一次使用,你的电脑上是没有配置文件的,执行下方的查询命令会自定在该路径下生成一个配置文件,比如我就是第一次使用

image

4.修改配置文件

windows电脑,右键打开方式,然后点击记事本

再按ctrl+F,查找关键词“c.NotebookApp.notebook_dir”

然后我们把这一行前面的#号删除,因为这代表这个配置被注释了,然后把我们前面创建的文件夹的路径放到这个配置后面的两个引号中去,结果如下:

image

保存配置后退出即可

5.验证

这时候我们退出之前打开的jupyter进程,然后重新启动jupyter进程,就可以看到当前目录发生了变化

image

三、操作简介

image


posted @   致丶幻  阅读(24)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 全程不用写代码,我用AI程序员写了一个飞机大战
· DeepSeek 开源周回顾「GitHub 热点速览」
· 记一次.NET内存居高不下排查解决与启示
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET10 - 预览版1新功能体验(一)
  1. 1 So Far Away (Acoustic) Adam Christopher
  2. 2 雪 Distance Capper&罗言RollFlash
  3. 3 CollapsingWorld
  4. 4 Call You Tonight Johnta Austin
So Far Away (Acoustic) - Adam Christopher
00:00 / 00:00
An audio error has occurred, player will skip forward in 2 seconds.

作曲 : David Guetta/Giorgio H Tuinfort/Jamie Scott/Martijn G Garritsen

Light ‘em up, light ‘em up

Tell me where you are, tell me where you are

The summer nights, the bright lights

And the shooting stars, they break my heart

I‘m calling you now, but you‘re not picking up

Your shadows so close if you are still in love

Then light a match, light a match

Baby, in the dark, show me where you are

Oh, love

How I miss you every single day when I see you on those streets

Oh, love

Tell me there‘s a river I can swim that will bring you back to me

‘Cause I don‘t know how to love someone else

I don‘t know how to forget your face

Oh, love

God, I miss you every single day and now you‘re so far away

It‘s breaking me, I‘m losing you

We were far from perfect, but we were worth it

Too many fights, and we cried, but never said we‘re sorry

Stop saying you love me

You‘re calling me now, but I can‘t pick up

Your shadow‘s too close, and I‘m still in love

The summer‘s over now, but somehow, it still breaks my heart

We could have had the stars, oh

Oh, love

How I miss you every single day when I see you on those streets

Oh, love

Tell me there‘s a river I can swim that will bring you back to me

‘Cause I don‘t know how to love someone else

I don‘t know how to forget your face

Oh, love

God, I miss you every single day and now you‘re so far away

Oh, love

How I miss you every single day when I see you on those streets

Oh, love

Tell me there‘s a river I can swim that will bring you back to me

‘Cause I don‘t know how to love someone else

I don‘t know how to forget your face

Oh, love

God, I miss you every single day when you‘re so far away

点击右上角即可分享
微信分享提示