Mac 上的 Jupyter:来自非默认目录的 运行 个文件

Jupyter on Mac: run files from non-default directory

我 运行 Jupyter Notebook 在 mac 上,我正在尝试从我贡献的 git 回购中编辑笔记本文件。但是,我无法从笔记本界面访问该文件。

有没有办法访问不在 mac 默认路径中的笔记本(导航到任意文件位置在 windows 上工作正常)而不将默认目录更改为我的 [=35] =] repo 而不是每次编辑时都将文件复制到我的默认目录并返回?

看起来路径外的直接导航是不可能的()但似乎应该可以使用命令行从给定目录启动笔记本。

我尝试过的事情:

  1. 直接在 Web 界面中输入与树相关的相对路径和绝对路径(即 http://localhost:8889/tree/../../[path-to-file]
  2. 以路径为前缀重命名文件
  3. 从包含笔记本的目录启动 jupyter

...目前还没有成功。

如有任何帮助,我们将不胜感激。

it seems that it should be possible to start the notebook from the given directory using the command line

你可以...

jupyter notebook /some/non-default/path

但是,您只能使用 Jupyter 访问该路径的子目录

Starting jupyter from the directory containing the notebook

这也应该有效

如果您 python 代码需要读取父目录中的文件,相对路径在笔记本内核中仍然可以很好地解析。