User Tools

Site Tools


jupyter_notebook

Table of Contents

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

详见:Jupyter Notebook介绍、安装及使用教程

安装

小白用户(并且磁盘剩余空间超过3G)推荐通过Anaconda安装,Anaconda包括Jupyter以及其他科学计算相关包。

Python高级用户可以使用Pip安装,安装包名称是jupyter

启动

jupyter notebook
# 指定端口
jupyter notebook --port <port_number>
# 不自动打开浏览器
jupyter notebook --no-browser

远程访问

详见:远程访问服务器Jupyter Notebook的两种方法

  • 生成默认配置文件
jupyter notebook --generate-config
  • 生成访问密码(token)

终端输入ipython,设置你自己的jupyter访问密码,注意复制输出的sha1:xxxxxxxx密码串:

In [1]: from notebook.auth import passwd
In [2]: passwd()
Enter password:
Verify password:
Out[2]: 'sha1:xxxxxxxxxxxxxxxxx'
  • 修改./jupyter/jupyter_notebook_config.py中对应行如下
c.NotebookApp.ip='*'
c.NotebookApp.password = u'sha:ce...刚才复制的那个密文'
c.NotebookApp.open_browser = False
c.NotebookApp.port =8888 #可自行指定一个端口, 访问时使用该端口

随后启动jupyter即可在同一网络中的任意电脑浏览器访问

jupyter_notebook.txt · Last modified: 2023/03/08 16:09 by xujianglong