打开jyputer notebook
开始菜单----->Anaconda Prompt (anaconda3)
?进入base环境,默认
(base) C:\User>
路径。想从pytorch环境下进入jupyter,激活pytorch环境。
(base) C:\develop\python_workspace\learn_pytorch>conda activate pytorch
在当前路径下,输入jupyter notebook,打开之后的路径应该是C:\develop\python_workspace\learn_pytorch,但依然是
C:\User>
(pytorch) C:\develop\python_workspace\learn_pytorch>jupyter notebook
输入?jupyter notebook + 想打开的路径
(pytorch) C:\develop\python_workspace\learn_pytorch>jupyter notebook C:\develop\python_workspace\learn_pytorch
此时 打开的是指定的路径C:\develop\python_workspace\learn_pytorch
如果不想每次输入jupyter notebook 再额外输入路径,很麻烦,可以采取删除默认路径的方法。
默认路径存储在哪里?
?打开Anaconda Prompt (anaconda3)
输入下面命令
jupyter-notebook --generate-config
出来一个文件名C:\Users\.jupyter\jupyter_notebook_config.py,用记事本打开
(base) C:\develop\python_workspace\learn_pytorch>jupyter notebook --generate-config
Overwrite C:\Users\.jupyter\jupyter_notebook_config.py with default config? [y/N]
(base) C:\develop\python_workspace\learn_pytorch>
打开提示的路径,下面是我的路径
C:\Users\.jupyter\jupyter_notebook_config.py with default config
?搜索文本内容‘directory’,大概在393行
## The directory to use for notebooks and kernels.
# Default: ''
c.NotebookApp.notebook_dir = 'C:\\Users\\Desktop\\NEUCS\\study\\Mathmatical Modeling\\jupyter\\workspace'
将第三行注释掉,保存文本。
看到网上其他方法都是修改为别的位置,但是也不是每次都想打开同一位置,索性去掉默认位置。
## The directory to use for notebooks and kernels.
# Default: ''
#c.NotebookApp.notebook_dir = 'C:\\Users\\Desktop\\NEUCS\\study\\Mathmatical Modeling\\jupyter\\workspace'
再次输入jyputer notebook,
(pytorch) C:\develop\python_workspace\learn_pytorch>jupyter notebook
此时打开的是当前路径C:\develop\python_workspace\learn_pytorch>,无需在jyputer notebook后面指定路径。