【问题标题】:Issue modifying Jupyter Home Directory修改 Jupyter 主目录的问题
【发布时间】:2018-05-12 01:05:10
【问题描述】:

有一次我将我的 Jupyter 主目录设置为 ~/Dropbox 不幸的是,由于 Dropbox 更改其文件夹名称的方式,该位置现在是我机器上指向隐藏目录的符号链接。这会导致 Jupyter 出现以下错误

Refusing to serve hidden directory '/Users/alex/Dropbox', via 404 Error

很好......我现在想更改我的 Jupyter 主目录,但我遇到的问题是我无法弄清楚它当前的设置位置。

我已经检查了我的~/.jupyter/jupyter_notebook_config.py,但这似乎与默认设置没有任何关系。

$jupyter --paths 的输出是:

config:
    /Users/alex/.jupyter
    /usr/local/Cellar/python@2/2.7.14_3/Frameworks/Python.framework/Versions/2.7/etc/jupyter
    /usr/local/etc/jupyter
    /etc/jupyter
data:
    /Users/alex/Library/Jupyter
    /usr/local/Cellar/python@2/2.7.14_3/Frameworks/Python.framework/Versions/2.7/share/jupyter
    /usr/local/share/jupyter
    /usr/share/jupyter
runtime:
    /Users/alex/Library/Jupyter/runtime

有趣的是,以下目录不存在。

/usr/local/Cellar/python@2/2.7.14_3/Frameworks/Python.framework/Versions/2.7/etc/jupyter
/usr/local/etc/jupyter
/etc/jupyter

/Users/alex/.jupyter/jupyter_notebook_config.py 中设置c.NotebookApp.notebook_dir = '/Users/alex/' 似乎没有效果。

$jupyter notebook
[I 18:26:34.756 NotebookApp] [nb_conda_kernels] enabled, 4 kernels found
[I 18:26:35.257 NotebookApp] The port 8888 is already in use, trying another port.
[I 18:26:35.258 NotebookApp] The port 8889 is already in use, trying another port.
[I 18:26:35.259 NotebookApp] The port 8890 is already in use, trying another port.
[I 18:26:35.260 NotebookApp] The port 8891 is already in use, trying another port.
[I 18:26:36.299 NotebookApp] [nb_anacondacloud] enabled
[I 18:26:36.304 NotebookApp] [nb_conda] enabled
[I 18:26:36.382 NotebookApp] ✓ nbpresent HTML export ENABLED
[W 18:26:36.382 NotebookApp] ✗ nbpresent PDF export DISABLED: No module named 'nbbrowserpdf'
[I 18:26:36.388 NotebookApp] Serving notebooks from local directory: /Users/alex
[I 18:26:36.388 NotebookApp] 0 active kernels
[I 18:26:36.388 NotebookApp] The Jupyter Notebook is running at:
[I 18:26:36.388 NotebookApp] http://localhost:8892/?token=289948463daed06187325be63202f620b812dddc14f2918a
[I 18:26:36.388 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
[C 18:26:36.389 NotebookApp] 

    Copy/paste this URL into your browser when you connect for the first time,
    to login with a token:
        http://localhost:8892/?token=289948463daed06187325be63202f620b812dddc14f2918a
[I 18:26:36.717 NotebookApp] Accepting one-time-token-authenticated connection from ::1
[I 18:26:37.252 NotebookApp] Refusing to serve hidden directory '/Users/alex/Dropbox', via 404 Error
[W 18:26:37.252 NotebookApp] 404 GET /api/contents?type=directory&_=1526088397023 (::1): directory does not exist: 'Dropbox'
[W 18:26:37.252 NotebookApp] directory does not exist: 'Dropbox'
[W 18:26:37.253 NotebookApp] 404 GET /api/contents?type=directory&_=1526088397023 (::1) 15.70ms referer=http://localhost:8892/tree

可以从哪里设置 Jupyter 主目录?

【问题讨论】:

    标签: jupyter-notebook jupyter jupyter-lab


    【解决方案1】:

    这是jupyter notebookthrow a 404 when starting it from a hidden folder 的预期行为。

    通常,jupyter notebook 将在您调用 jupyter notebook 命令的文件夹中启动。所以cd 进入你希望它运行的目录,并在那里发出jupyter notebook

    如果这不起作用,您可以尝试使用jupyter notebook --notebook-dir=NEWDIR 之类的命令行参数强制目录。

    否则,您会在上面提到一个全局配置和一个本地(每个用户)配置。如果本地是默认值,那么您可能之前更改了全局配置。如果您将 ~/.jupyter/jupyter_notebook_config.py 中的本地配置更改为应该覆盖全局配置的新值。

    要清理全局配置,请在 Unix 上的 /etc/jupyter/usr/local/etc/jupyter/ 或 Windows 上的 %PROGRAMDATA%\jupyter\ 中查找它。

    您可以列出与命令jupyter --paths 一起使用的当前配置路径。更多信息在manual

    【讨论】:

    • 感谢您的 cmets .. 我根据您的建议添加了更多细节,但仍然没有运气。
    • 你的操作系统是什么?另外,您是否尝试过更改要从中运行 jupyter 的目录并从那里发出 jupyter notebook 命令?
    • macOS 10.13.4 (17E202) ... 使用 anaconda conda -V conda 4.5.2。无论我尝试从哪里运行jupyter notebook,它都默认为~/Dropbox
    • 你试过jupyter notebook --notebook-dir=NEWDIR吗?
    • 现在我们正在取得进展……jupyter notebook --notebook-dir=NEWDIR 有效,但每次都这样做显然很痛苦。
    猜你喜欢
    • 2021-10-09
    • 1970-01-01
    • 1970-01-01
    • 2018-03-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多