首页 > 解决方案 > 在 Anaconda 中创建多个 Jupyter 工作目录/配置文件

问题描述

我的工作计算机上有 Anaconda Navigator,我已使用此处给出的步骤将 Jupyter 笔记本的默认工作目录更改为公司服务器上的某个位置

我还在 Anaconda 中创建了第二个环境,我想为此使用与基础(根)不同的 Jupyter Notebook 工作目录。为此,我相信我需要:

  1. 创建第二个 Jupyter Notebook 配置文件
  2. 获取第二个环境来引用新的配置文件,同时确保旧文件仍然引用原始配置文件。

我该怎么办?也欢迎创建多个工作目录的替代方法。

标签: pythonjupyter-notebookanacondaconfigconda

解决方案


Was looking to achieve the same result: pass different configurations which would include specific settings such as working and workspace directories when launching Jupyter Notebook/Lab in different conda or other virtual environments.

Noticing the following:

jupyter lab --help

  --config=<Unicode>
      Full path of a config file.
      Default: ''
      Equivalent to: [--JupyterApp.config_file]

Thus, to achieve the desired result, it is possible to pass the path to the relevant config file upon launching Jupyter Lab/Notebook as such:

jupyter lab --config=~/.jupyter/path_to_my_custom_jupyter_config_for_env_1.py
# or
jupyter notebook --config=~/.jupyter/path_to_my_custom_jupyter_config_for_env_1.py

You can copy your current configuration file, make the relevant adjustments and save it as a different file. You would then pass the path to that new config file when launching Jupyter as per above. To simplify, you can create shortcuts that do that (instead of typing/copying the specific parameters on each launch).

Otherwise (with no specific argument passed), Jupyter Lab/Notebook will launch using the default configuration file if it exists, which is always located in the home directory of the Unix user launching Jupyter (~/.jupyter/jupyter_notebook_config.py).


推荐阅读