修改Jupyter NoteBook默认打开路径
1.打开Anaconda Promot命令行,输入以下命令:
jupyter notebook --generate-config
2.在C盘->Users->Administrator(你自己的账户名)下,找到.jupyter文件夹,找到jupyter_notebook_config.py文件,用记事本打开,修改以下内容(大致在393行左右):
c.NotebookApp.notebook_dir = 'E:\jupterProject'
创建的环境并加入到Jupyter NoteBook内核
1.创建虚拟环境
conda create -n 环境名 python=版本号
2.进入环境
activate 环境名
3.安装ipykernel
pip install ipykernel -i https://pypi.mirrors.ustc.edu.cn/simple
4.将虚拟环境添加到内核
python -m ipykernel install --user --name=环境名
打开jupyter notebook 创建文件时选择你创建的环境即可。
参考:https://blog.youkuaiyun.com/qq_38130747/article/details/118312372
Jupyter Notebook代码提示/自动补全/代码格式化
打开Anaconda Promot命令行,输入以下l两个安装命令:
1.安装 nbextensions
pip install jupyter_contrib_nbextensions -i https://pypi.mirrors.ustc.edu.cn/simple
jupyter contrib nbextension install --user
2.安装 nbextensions_configurator
pip install --user jupyter_nbextensions_configurator
jupyter nbextensions_configurator enable --user
然后重新启动 jupyter notebook,点击新增加的Nbextensions项

取消勾选下图所示选项

然后勾选Hinterland(代码提示/自动补全)和Autopep8(代码格式化)

回到jupyter notebook 重新创建新项目,代码提示和自动补全的设置就完成了!
注意:勾选Autopep8(代码格式化)需要在对应的环境中安装Autopep8:
pip install autopep8
点击工具栏右边的小锤子就可以实现代码格式化了!

参考:https://www.pianshen.com/article/37961710387/
本文介绍了如何修改Jupyter Notebook的默认工作目录,并详细讲解了如何创建虚拟环境、安装内核、启用代码提示和自动补全,以及使用nbextensions配置代码格式化。
3043





