当前位置:   article > 正文

jupyter notebook无法以当前所在路径打开,总是默认C盘,如何删除默认位置_jupyter只能在c盘路径下?

jupyter只能在c盘路径下?


问题描述

打开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,用记事本打开

  1. (base) C:\develop\python_workspace\learn_pytorch>jupyter notebook --generate-config
  2. Overwrite C:\Users\.jupyter\jupyter_notebook_config.py with default config? [y/N]
  3. (base) C:\develop\python_workspace\learn_pytorch>

打开提示的路径,下面是我的路径

C:\Users\.jupyter\jupyter_notebook_config.py with default config

 搜索文本内容‘directory’,大概在393行

  1. ## The directory to use for notebooks and kernels.
  2. # Default: ''
  3. c.NotebookApp.notebook_dir = 'C:\\Users\\Desktop\\NEUCS\\study\\Mathmatical Modeling\\jupyter\\workspace'

将第三行注释掉,保存文本。

看到网上其他方法都是修改为别的位置,但是也不是每次都想打开同一位置,索性去掉默认位置。

  1. ## The directory to use for notebooks and kernels.
  2. # Default: ''
  3. #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后面指定路径。

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/正经夜光杯/article/detail/908546
推荐阅读
相关标签
  

闽ICP备14008679号