@myles
        
        2019-01-08T12:03:46.000000Z
        字数 3903
        阅读 1173
    未分类
简而来说,Jupyter Notebook 就是以网页的形式打开,我们可以在网页页面中直接编写代码和运行代码,代码的运行结果也会直接在代码块下显示的程序。如在编程过程中需要编写说明文档,也可在同一个页面中直接编写,便于作及时的说明和解释。
这里必须要说下 pip3 更新,为什么要记录pip版本更新,因为踩到坑了,所有要记录下。
# python3 -m pip3 install --upgrade pip# 注意:这里更新完pip3后,pip3就不可用了(坑:会报错),后面直接使用pip install jupyter即可完安装。
# python3 -m pip install jupyter
这里要重点说下的notebook服务管理,我们可以在系统层面基于命令进行直接配置管理的,比起早先版本的配置文件管理更为人性化了,这里会重点说下3个命令:
root@Docker_Lab_01:/home/tmp# jupyter notebook --helpThe Jupyter HTML Notebook.这将启动一个基于tornado的HTML笔记本服务器,它提供一个html5/javascript笔记本客户端。Subcommands-----------Subcommands are launched as `jupyter-notebook cmd [args]`. For information onusing subcommand 'cmd', do: `jupyter-notebook cmd -h`.stopStop currently running notebook server for a given portpasswordSet a password for the notebook server.list列出当前运行的Notebook服务.Options-------Arguments that take values are actually convenience aliases to fullConfigurables, whose aliases are listed on the help line. For more informationon full configurables, see '--help-all'.-yAnswer yes to any questions instead of prompting.--debugset log level to logging.DEBUG (maximize logging output)--no-scriptDEPRECATED, IGNORED--allow-root允许notebook在root用户下运行.--no-browser在启动服务以后不在浏览器中打开一个窗口.--scriptDEPRECATED, IGNORED--generate-configgenerate default config file--pylabDISABLED: use %pylab or %matplotlib in the notebook to enable matplotlib.--no-mathjaxDisable MathJaxMathJax is the javascript library Jupyter uses to render math/LaTeX. It isvery large, so you may want to disable it if you have a slow internetconnection, or for offline use of the notebook.When disabled, equations etc. will appear as their untransformed TeX source.--certfile=<Unicode> (NotebookApp.certfile)Default: ''SSL/TLS 认证文件所在全路径.--port-retries=<Int> (NotebookApp.port_retries)Default: 50如果指定的端口不可用,则要尝试其他端口的数量.--port=<Int> (NotebookApp.port)Default: 8888notebook服务会监听的IP端口.--transport=<CaselessStrEnum> (KernelManager.transport)Default: 'tcp'Choices: ['tcp', 'ipc']--ip=<Unicode> (NotebookApp.ip)Default: 'localhost'notebook服务会监听的IP地址.--config=<Unicode> (JupyterApp.config_file)Default: ''Full path of a config file.--client-ca=<Unicode> (NotebookApp.client_ca)Default: ''用于ssl/tls客户端身份验证的证书颁发证书的完整路径.--keyfile=<Unicode> (NotebookApp.keyfile)Default: ''SSL/TLS 私钥文件所在全路径.--log-level=<Enum> (Application.log_level)Default: 30Choices: (0, 10, 20, 30, 40, 50, 'DEBUG', 'INFO', 'WARN', 'ERROR', 'CRITICAL')Set the log level by value or name.--pylab=<Unicode> (NotebookApp.pylab)Default: 'disabled'DISABLED: use %pylab or %matplotlib in the notebook to enable matplotlib.--notebook-dir=<Unicode> (NotebookApp.notebook_dir)Default: ''用于笔记本和内核的目录。--browser=<Unicode> (NotebookApp.browser)Default: ''Specify what command to use to invoke a web browser when opening thenotebook. If not specified, the default browser will be determined by the`webbrowser` standard library module, which allows setting of the BROWSERenvironment variable to override it.To see all available configurables, use `--help-all`Examples--------jupyter notebook # start the notebookjupyter notebook --certfile=mycert.pem # use SSL/TLS certificatejupyter notebook password # enter a password to protect the serve
初次远程登录需要附带token密码进行访问,或输入密码进行登录访问,密码的设置,直接在开启服务器以下命令进行密码设置即可。
# 直接使用如下的命令行,即可完成notebook远程登录密码的设置root@Docker_Lab_01:/home/tmp# jupyter notebook passwordEnter password:Verify password:[NotebookPasswordApp] Wrote hashed password to /root/.jupyter/jupyter_notebook_config.json# 密码文件查看,可以看到已经为 notebook添加好密码root@Docker_Lab_01:/home/iflytek/tmp# cat /root/.jupyter/jupyter_notebook_config.json{"NotebookApp": {"password": "sha1:c2b02dd5dc21:d563ad9b691d7f8c5374738d9003c035b654d40b"}
jupyter notebook 应用服务默认只能在本地基于浏览器访问交互式服务,如果要开启远程访问权限,需要在启动服务试开启远程接口监听,具体方法如下。
# jupyter notebook --ip=0.0.0.0 --allow-root
在开启notebook 服务时,设定开启服务的监听端口为 0.0.0.0 即可开启远程浏览器访问:http://notebook_host:8888