jupyter的安装与简易使用教程
ps:具体教程见官方文档https://jupyter-notebook.readthedocs.io/en/stable/notebook.html
同时,推荐看这个作者的详细中文教程https://www.jianshu.com/p/91365f343585
我的环境:window10+python3.6,(可先查看已安装组件:python -m pip list)
运行:
pip3 install jupyter
jupyter notebook
在打开的浏览器页面,点击新建python文件,然后输入以下demo
cell运行快捷键:
ctrl + enter :run cell
shift + enter: run cell and select below
Alt + enter:执行单元格代码,新建并移动到下一个单元格
示例:
1、输入%lsmagic后按ctrl + enter运行cell。
2、获取当前所在位置的绝对路径:点击insert,新增代码段,输入%pwd后按ctrl + enter运行cell。
3、%%timeit
square_evens = [n*n for n in range(1000)]
4、
import pandas as pd
import numpy as np
df = pd.DataFrame(np.random.randn(8,5))
df.head()
5、运行python文件:
方法一:%run file.py
方法二:!python myfile.py
加载本地python文件是:%load Python文件的绝对路径
6、导入外部文件
%load test.py #test.py是当前路径下的一个python文件
下载文件并打开:
$ mv ~/Downloads/Trapezoid\ Rule.ipynb ./
ls
7、加载指定网页源代码
%load URL
其中,URL为指定网站的地址。
查看自己notebook配置文件在哪里:jupyter notebook --generate-config
通过在终端中按两次Ctrl+c,可以关闭整个服务器
C:\Program Files (x86)\Google\Chrome\Application\chrome.exe
更改文件存放路径:
根据你运行实际显示的路径,打开这个配置文件(可以用notepad++软件打开各种格式的文件),我电脑上是这个文件C:\Users\lwx\.jupyter\jupyter_notebook_config.py
搜索:#c.NotebookApp.notebook_dir = '',更改自定义路径名。
## The directory to use for notebooks and kernels.
c.NotebookApp.notebook_dir = '/Users/lwx/wendy_jupyter'
在配置文件中修改默认浏览器,
搜索:browser =
把路径添加进去,我的是:
C:\Program Files (x86)\Google\Chrome\Application\chrome.exe