zoukankan      html  css  js  c++  java
  • Jupyter Notebook搭建

    1. 前言

    notebook需要搭建jupyter环境,而jupyter需要pip安装,而pip又需要python环境.
    
    而notebook其实就是一个在浏览器中的ipython.不过它能更好的做好记录,日记和备份,教学都是一个不错的工具.
    

    2. jupyter搭建

    2.1 安装
       $ pip install jupyter
    
    2.1 jupyter 基础用法
       $ jupyter -h  
    

    3. notebook的使用

    3.1 启动notebook
      $ jupyter notebook
    

    4. jupyter的配置

    4.1 生成配置文件
       $ jupyter notebook --generate-config
       使用以上命令之后会在当前用户目录生成一个.jupyter的文件夹,
       文件夹中有个 jupyter_notebook_config.py的文件就是我们所需要的配置文件,
       可使用文本工具(xcode,sublime text)打开.
    
    4.2 密码生成
       $ ipython
    
    glbooks $ ipython
    Python 3.8.9 (default, Aug  3 2021, 19:21:54) 
    Type 'copyright', 'credits' or 'license' for more information
    IPython 7.29.0 -- An enhanced Interactive Python. Type '?' for help.
    
    In [1]: from notebook.auth import passwd
    
    In [2]: passwd()
    Enter password: 
    Verify password: 
    Out[2]: 'argon2:$argon2id$v=19$m=10240,t=10,p=8$6D+2naAe1jJvctSA5P79Ww$pgUh0C3g9XwBsU1DdY6gtg'
    
    In [3]: exit()
    
    
    4.3 修改配置文件
    
        c.NotebookApp.notebook_dir = '/User/ios/glbooks' # 内核目录,默认为执行命令的目录. 设置'~/glbooks' 会报错,无法正常工作
        c.NotebookApp.ip = '*' #设置所有ip皆可访问,默认为localhost.
        c.NotebookApp.open_browser = False #禁止启动就打开浏览器,模式是开启
        c.NotebookApp.port = 8989 # 指定一个端口号,默认为8888
        c.NotebookApp.password = 'argon2:$argon2id$v=19$m=10240,t=10,p=8$6D+2naAe1jJvctSA5P79Ww$pgUh0C3g9XwBsU1DdY6gtg' # 指定密码
    
    4.4 启动之后的效果
    
    glbooks $ jupyter notebook
    [W 11:15:58.184 NotebookApp] WARNING: The notebook server is listening on all IP addresses and not using encryption. This is not recommended.
    [I 11:15:58.189 NotebookApp] 启动notebooks 在本地路径: /Users/ios/glbooks
    [I 11:15:58.189 NotebookApp] Jupyter Notebook 6.4.5 is running at:
    [I 11:15:58.189 NotebookApp] http://ios-mac-mini.local:8889/?token=344f308b4b858e1560f89a5293359726aa75154540b5b360
    [I 11:15:58.189 NotebookApp]  or http://127.0.0.1:8889/?token=344f308b4b858e1560f89a5293359726aa75154540b5b360
    [I 11:15:58.189 NotebookApp] 使用control-c停止此服务器并关闭所有内核(两次跳过确认).
    [C 11:15:58.193 NotebookApp] 
        
        To access the notebook, open this file in a browser:
            file:///Users/ios/Library/Jupyter/runtime/nbserver-99918-open.html
        Or copy and paste one of these URLs:
            http://ios-mac-mini.local:8889/?token=344f308b4b858e1560f89a5293359726aa75154540b5b360
         or http://127.0.0.1:8889/?token=344f308b4b858e1560f89a5293359726aa75154540b5b360
    

    注: 在修改配置文件的时候,删除‘#’后别忘记把前面的一个空格删除,不然启动notebook的时候会报错

  • 相关阅读:
    [Algorithms] Counting Sort
    [LeetCode] Sort Colors
    [LeetCode] Contains Duplicate III
    [LeetCode] Contains Duplicate
    [LeetCode] Two Sum II
    [LeetCode] Linked List Cycle II
    [LeetCode] Linked List Cycle
    [LeetCode] Longest Palindromic Substring
    [LeetCode] Two Sum
    [LeetCode] Rectangle Area
  • 原文地址:https://www.cnblogs.com/gulong/p/12767905.html
Copyright © 2011-2022 走看看