【问题标题】:using jupyter notebook in pycharm - no such notebook dir在 pycharm 中使用 jupyter notebook - 没有这样的 notebook 目录
【发布时间】:2016-07-25 20:58:57
【问题描述】:

我正在尝试使用 PyCharm 2016.1 中的 jupyter notebook。我打开一个之前创建的 iPython 笔记本,单击包含代码的单元格,然后运行它。系统提示我在默认 url 启动 jupyter notebook,然后单击 OK。以下是来自“运行”窗口的错误消息:

[C 13:04:23.979 NotebookApp] Bad config encountered during initialization:
The Jupyter HTML Notebook.
[C 13:04:23.979 NotebookApp] No such notebook dir: 'C:\\Users\\cb4\\Documents\\python'

在 PyCharm 中使用默认 url 启用了 iPython Notebook。

【问题讨论】:

    标签: pycharm jupyter-notebook


    【解决方案1】:

    Jupyter 将配置信息保存在 jupyter_notebook_config.py 文件中。您可以在 Windows 上的 C:\Users\<user>\.jupyter 或 Linux 上的 ~\.jupyter 中找到它。将c.NotebookApp.notebook_dir 条目修改为您保存笔记本的位置。也可以使用命令行来设置:

    jupyter-notebook --notebook-dir=<path>
    

    如果路径名中有空格,则在 Windows 上用双引号将 &lt;path&gt; 括起来。

    如果您在升级到 jupyter 之前安装了 iPython,那么 jupyter migration process 使用旧 iPython 配置文件中的设置。也许您已经很长时间没有修改 iPython,这就是为什么您会看到 jupyter 出现意外的启动或运行行为。

    此外,这个 jupyter 命令可能有助于解决目录/路径问题:

    jupyter --paths
    

    【讨论】:

    • 如果配置文件错误,有时--notebook-dir option 会失败,这就是为什么 Simon Brunner 的回答也很有用。如果你赶时间不想修复配置文件,你可以cd 到你想要的目录并在没有 notebook-dir 选项的情况下启动 jupyter notebook。
    【解决方案2】:

    刚刚遇到同样的问题,用下面的命令解决了:

    jupyter notebook --generate-config
    

    更多信息在这里:http://jupyter-notebook.readthedocs.io/en/stable/config.html

    它提示我将当前配置替换为默认配置。因此,如果您可以摆脱当前的配置,这是一个简单的选择。

    【讨论】:

      【解决方案3】:

      我通过以下方式解决了这个问题:

      以管理员身份打开 cmd

      输入:

      jupyter notebook --config=/home/john/mystuff/jupyter_notebook_config.json
      

      请注意: 在运行上述脚本之前,请确保必须卸载 Anaconda 和 Jupyter Lab

      • 删除C:/盘中的所有文件
      • 然后安装重新安装最新的 Python3 ,并正确添加/设置环境路径,并建议在主根文件夹中将 Pyhon 设置为 C:/Python 而不是 c:/User/.../Python ,但是你需要安装 Jupyter notebook 使用:pip install Jupyter notebook **有时你需要安装 get-pip.py 才能使用 pip
      • 有时会出现 jupyter_notebook_config.py 丢失的情况,要创建一个 jupyter_notebook_config.py 文件,安装 python 后,
      • 您可以使用以下命令行:

      jupyter notebook --generate-config

      【讨论】:

        猜你喜欢
        • 2022-06-12
        • 2021-01-14
        • 1970-01-01
        • 2017-07-27
        • 2018-09-30
        • 2016-11-29
        • 1970-01-01
        • 1970-01-01
        • 2017-01-21
        相关资源
        最近更新 更多