【python】jupyter notebook 安装 和简单配置、使用

2021-03-11 21:28

阅读:512

标签:time   html   use   https   oca   服务   system   rate   pytho   

1. 介绍

2. 安装

pip install jupyter

如果pip安装失败,可以参考一下 【Python】pip配置国内镜像源,让Python模块安装飞起来。

3. 配置

  1. 更改workspace

notebook默认把启动时的当前路径作为默认的工作空间(workspace),也可以自定义。

REM step1 查看jupyter配置文件的位置
C:\WINDOWS\system32>jupyter notebook --generate-config
Writing default config to: C:\Users\Artchy\.jupyter\jupyter_notebook_config.py (Linux路径则是 ~/.jupyter\jupyter_notebook_config.py) 
       
REM step2 设置 c.NotebookApp.notebook_dir配置项,即工作空间路径    
    
REM step3 重启 notebook

4. 简单使用(控制台命令)

(1) 启动

其它几个常用的启动选项(详情使用jupyter notebook -h查看)
jupyter notebook # 全部使用默认
jupyter notebook [--ip 192.168.1.2] [--port 8888] [--autoreload] [--no-browser] [--debug] [--log-level ‘INFO‘]

C:\WINDOWS\system32>jupyter notebook --port 8888
[I 20:26:47.156 NotebookApp] Serving notebooks from local directory: E:\jupyter-workspace
[I 20:26:47.156 NotebookApp] Jupyter Notebook 6.1.5 is running at:
[I 20:26:47.157 NotebookApp] http://localhost:8888/?token=7d45cdc126efe6d06b39df37355c39fd083a8379f70c8ab3
[I 20:26:47.157 NotebookApp]  or http://127.0.0.1:8888/?token=7d45cdc126efe6d06b39df37355c39fd083a8379f70c8ab3
[I 20:26:47.158 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
[C 20:26:47.418 NotebookApp]

    To access the notebook, open this file in a browser:
        file:///C:/Users/Artchy/AppData/Roaming/jupyter/runtime/nbserver-8988-open.html
    Or copy and paste one of these URLs:
        http://localhost:8888/?token=7d45cdc126efe6d06b39df37355c39fd083a8379f70c8ab3
     or http://127.0.0.1:8888/?token=7d45cdc126efe6d06b39df37355c39fd083a8379f70c8ab3

(2) 查看已经启动的jupyter notebook服务

C:\WINDOWS\system32>jupyter notebook list
Currently running servers:
http://localhost:8888/?token=bd335620c3ca66393c9ed8fad81d9b6fbda722f530e22816 :: E:\jupyter-workspace

(3) 停止

两次ctrl+c即可强制停止。另外可以另开一个窗口然后执行jupyter notebook stop

C:\WINDOWS\system32>jupyter notebook stop
Shutting down server on 8888...

可能遇到

  1. 在windows后台打开服务,并且不自动进入页面。
    start /b jupyter notebook --no-browser

  2. 对于在后台打开的服务,ctrl+c和jupyter notebook stop关不掉,需要登录到页面关闭服务。
    技术图片

【python】jupyter notebook 安装 和简单配置、使用

标签:time   html   use   https   oca   服务   system   rate   pytho   

原文地址:https://www.cnblogs.com/bing-tang/p/python-jupyter.html


评论


亲,登录后才可以留言!