您好,欢迎来到伴沃教育。
搜索
您的当前位置:首页python之jupyter notebook

python之jupyter notebook

来源:伴沃教育

  jupyter是一种交互式计算和开发环境的笔记,ipython命令行比原生的python命令行更加友好和高效,还可以运行web版的界面,支持多语言,输出图形、音频、视频等功能。

 

安装

  

pip install jupyter

 

使用

  

ipython

 

  2.   运行shell命令

感叹号!+shell直接运行shell命令,如!pwd
运行python文件

%run test.py(python文件)

 

魔术函数的使用:
%time a = np.arange(1000)    

 

%quickref 显示IPython的快速参考

%magic 显示所有魔术命令的详细文档
%debug 从最新的异常跟踪的底部进入交互式调试器
%hist 打印命令的输入(可选输出)历史
%pdb 在异常发生后自动进入调试器
% paste  执行剪贴板中的Python代码
%cpaste 打开一个特殊提示符以便手工粘贴待执行的Python代码
%reset 删除interactive命名空间中的全部变量/名称
%page OBJECT 通过分页器打印输出OBJECT
%run script.py 在IPython中执行一个Python脚本文件
%prun statement 通过cProfile执行statement,并打印分析器的输出结果
% time  statement 报告statement的执行时间
%timeit statement 多次执行statement以计算系综平均执行时间。对那些执行时 间非常小的代码很有用
% who 、%who_ls、%whos 显示interactive命名空间中定义的变量,信息级别/冗余度可变
%xdel variable 删除variable,并尝试清除其在IPython中的对象上的一切引用

 

 

  3.  运行web ipython环境

jupyter notebooke --ip=127.0.0.1 --port=8888

更多参数:

这将启动一个基于tornado的HTML笔记本服务器,它提供一个html5/javascript笔记本客户端。

Subcommands
-----------

Subcommands are launched as `jupyter-notebook cmd [args]`. For information on
using subcommand 'cmd', do: `jupyter-notebook cmd -h`.

list
列出当前运行的Notebook服务.
stop
Stop currently running notebook server for a given port
password
Set a password for the notebook server.

Options
-------

Arguments that take values are actually convenience aliases to full
Configurables, whose aliases are listed on the help line. For more information
on full configurables, see '--help-all'.

--debug
set log level to logging.DEBUG (maximize logging output)
--generate-config
generate default config file
-y
Answer yes to any questions instead of prompting.
--no-browser
在启动服务以后不在浏览器中打开一个窗口.
--pylab
DISABLED: use %pylab or %matplotlib in the notebook to enable matplotlib.
--no-mathjax
Disable MathJax

MathJax is the javascript library Jupyter uses to render math/LaTeX. It is
very large, so you may want to disable it if you have a slow internet
connection, or for offline use of the notebook.

To see all available configurables, use `--help-all`

Examples
--------

jupyter notebook # start the notebook
jupyter notebook --certfile=mycert.pem # use SSL/TLS certificate
jupyter notebook password # enter a password to protect the server

 

 

  常用命令:

    1.  查看配置文件

jupyter notebook --generate-config

    如果配置文件不存在, 创建

ipython profile create

 

 

  常用快捷键:

  • 执行当前cell,并自动跳到下一个cell:Shift Enter
  • 执行当前cell,执行后不自动调转到下一个cell:Ctrl-Enter
  • 为一行或者多行添加/取消注释:Crtl /<br>打开帮助,Ctrl+Shirt+P

 

 


  1. 添加代码自动补全

pip install jupyter_contrib_nbextensions

安装完成,需要配置
jupyter contrib nbextension install --user --skip-running-check

启动jupyter notebook

页面上会出现 Nbextensions
    勾选 Hinterland即可

具体使用的时候, 使用tab进行代码补全操作

 

 

 

 
 
 
 
 
 

转载于:https://www.cnblogs.com/xingxia/p/python_jupyter-notebook.html

因篇幅问题不能全部显示,请点此查看更多更全内容

Copyright © 2019- bangwoyixia.com 版权所有 湘ICP备2023022004号-2

违法及侵权请联系:TEL:199 1889 7713 E-MAIL:2724546146@qq.com

本站由北京市万商天勤律师事务所王兴未律师提供法律服务