目录
1下载安装
2 修改代码存储路径
3 打开指定位置的代码
问题:一直打开默认文件,什么问题?
其他简单使用:
4 新建+编译5 行号6 代码换行7 虚拟环境中使用jupyter
8 非默认浏览器打开
1下载安装
pip install jupyter // python环境中下载jupyter notebook // cmd打开
参考:【软件安装】Anaconda+Jupyter Notebook+Tensorflow+Graphviz+pycharm汉化
文中第2节已经把pip、Anconda的两种安装方式都写上了
2 修改代码存储路径
// cmd创建配置文件
jupyter notebook --generate-config// 若已存在,output>overwrite
// 创建成功,output>文件位置

文章图片
【【软件安装】Jupyter Notebook的安装和使用】打开py文件,找到下面这这段话:(搜索 c.NotebookApp.notebook_dir 即可)

文章图片

文章图片
① 删除前面的 #
②在’ ‘中添加需要保存的路径,用双斜杠\分割路径(测试:win 单斜杠\也可以)
③如果不行,在’ '前面加个u试试
④保存文件,重启jupyter
3 打开指定位置的代码 很多时候文件不在默认位置,可以打开cmd或者anaconda prompt,cd到指定位置,然后打开jupyter

文章图片
如果这个文件已存在,可以修改运行环境:

文章图片
问题:一直打开默认文件,什么问题? 如果改过配置文件.jupyter的默认代码存储位置的,会一直打开默认文件夹。打开配置文件,注释掉就可以了。

文章图片

文章图片
4 新建+编译

文章图片

文章图片
5 行号 点击【Toggle Line Numbers】,可以出现行号

文章图片

文章图片
6 代码换行 代码后面输入【\】,再点击【Enter】,可以较为整洁地让代码换行

文章图片
7 虚拟环境中使用jupyter 关于虚拟环境的使用,可以看【已解决】python 虚拟环境的三种方法+处理问题:Read timed out.
// 在虚拟环境中,安装jupyter的核心插件
(py37-common) D:\codes\src>pip install -i https://pypi.douban.com/simple ipykernal
// 在虚拟环境中,加载jupyter
// 标准格式:python -m ipykernel install --user --name 虚拟环境名字 --display-name "展示名字"
(py37-common) D:\codes\src>python -m ipykernel install --user --name py37-common
关闭后再打开jupyter,就可以发现新的虚拟环境了!

文章图片
8 非默认浏览器打开 在非系统默认的浏览器上打开jupyter notebook,需要输入一个token

文章图片
实际上这个token就在这里,把框中token=后面的语句复制粘贴即可

文章图片