Python .ipynb 文件

1,741 阅读2分钟

windows 环境

一、 .ipynb 文件是什么?

“ipynb” 文件是使用 Jupyter Notebook 来编写Python程序时的文件。

Jupyter Notebook(此前被称为 IPython notebook)是一个交互式笔记本

二、 怎么使用

  • 安装jupyter

不用你是用pip 还是anaconda 安装jupyter 都要对应环境 pip install jupyter

配置文件一般路径是在C:\Users${UserName}.jupyter\jupyter_notebook_config.py

  • 命令行界面运行jupyter
jupyter notebook
jupyter notebook --port=8890
// 或者
jupyter server 也可以运行,但是命令行不能断开

如果已经安装成功,下面是运行成功界面

image.png

  • 查看
访问直接点击url会跳转到浏览器中
http://localhost:8891/tree?token=7400a98e08908eb1907dca181b8adc4e0770dc9813ac4d0f

查看已经存在的jupyter服务 jupyter notebook listjupyter server list

  • 结束jupyter服务
  1. 浏览器中 File -> shut down
  2. 如果是jupyter server启动的,ctrl+c 中断服务, 直接关掉命令界面没有用
  3. 如果是jupyter notebook启动的, notebook list 查看端口, 停掉端口
jupyter notebook list
jupyter notebook stop 8889

我这边stop结束报错,服务确实停止了,(1)url链接无法访问了,(2)检查端口命令,端口已经停止了

但是 jupyter server list 还能查到

  • 检查
// 检查端口是否开启
netstat -ano | findstr :8889

其他

  1. 关联网站:nbviewer nbviewer.org/

  2. 百度的这个停止指令是错的, jupyter notebook stop --endpoint=http://localhost:8888

  3. jupyter server 和 jupyter notebook 的区别

Jupyter Notebook 是一个具体的前端应用,提供交互式笔记本的用户界面。 Jupyter Server 是一个后端服务,管理和执行代码,并支持多个不同的前端应用。 jupyter server list 更加贴近 Jupyter 当前的发展方向,尤其是在你使用 JupyterLab 或其他前端时,这个命令可能会显得更加通用。

  1. Katex | latex