【问题标题】:IPython notebook won't read the configuration fileIPython notebook 不会读取配置文件
【发布时间】:2015-08-12 20:30:24
【问题描述】:

我使用以下命令来初始化配置文件:

ipython profile create myserver

将这些行添加到~/.ipython/profile_myserver/ipython_notebook_config.py:

c = get_config()
c.NotebookApp.ip = '*'
c.NotebookApp.port = 8889

尝试使用以下方式启动笔记本:

ipython notebook --profile=myserver --debug

它根本不读取配置文件。 这是日志输出:

[W 16:26:56.607 NotebookApp] Unrecognized alias: '--profile=myserver', it will probably have no effect.
[D 16:26:56.609 NotebookApp] Config changed:
[D 16:26:56.609 NotebookApp] {'profile': u'myserver', 'NotebookApp': {'log_level': 10}}
...
[I 16:26:56.665 NotebookApp] 0 active kernels 
[I 16:26:56.665 NotebookApp] The IPython Notebook is running at: http://localhost:8888/

由于我已经明确指定了 8889 端口并且它仍然在 8888 上运行,它显然忽略了配置文件。我错过了什么?

【问题讨论】:

  • 你用的是哪个版本?
  • IPython 4.0.0。蟒蛇2.7.9。 @Cyphase
  • 试试ipython --profile=myserver notebook --debug。如果可行,我会发布答案。
  • 这就是问题所在!配置 jupyter 而不是 ipython 并以 jupyther notebook --profile=myserver 启动它解决了这个问题。谢谢!请随时添加答案:)
  • 完成。另外,我在您的帖子中添加了“jupyter”标签,但您可以自己做,因为我的编辑需要获得批准。这将使人们更容易找到。随着新版本刚刚发布,我预计其他人会在接下来的几天及以后遇到这种情况。

标签: python ipython ipython-notebook jupyter


【解决方案1】:

IPython 现在已移至 version 4.0,这意味着如果您正在使用它,它将从 ~/.jupyter 读取其配置,而不是 ~/.ipython。您必须使用

创建一个新的配置文件
jupyter notebook --generate-config

然后根据您的需要编辑生成的~/.jupyter/jupyter_notebook_config.py 文件。

更多安装说明here.

【讨论】:

  • ~/.ipython 中的所有配置文件文件夹会发生什么情况?他们被忽视了吗?我需要将它们复制到~/.jupyter吗?
  • @raxacoricofallapatorius,我不会只是复制它们,因为 API 发生了一些变化。最好的办法是手动编辑新配置,复制旧配置中的任何设置并阅读新配置中的 cmets 以了解 API 更改。是的,它们被忽略(AFAIK)。
  • 这是有道理的。不过,并非所有内容都需要移动/重新创建,对吗?似乎某些东西(例如ipython_config.py)仍在使用(至少在笔记本之外)。我不清楚ipython 在哪里读取它的配置,而ipython notebook 在哪里读取它的配置(或者就此而言,其他内核会发生什么)。
  • @raxacoricofallapatorius,你真的必须阅读installation instructions for Jupyter。我没有尝试过,但在我看来,对于控制台应用程序,您应该运行jupyter console --generate config。对于内核,我相信这个过程没有改变。我没有对他们做任何事情,但他们为我工作,所以也许它仍然从 ~/.ipython 读取。
  • 文档中的这一部分很有帮助:Migrating from IPython 我用于笔记本服务器的 IPython 配置无需更改。 jupyter notebook之后:The IPython Notebook is running at: https://10.0.1.207:10000/
【解决方案2】:

不要使用ipython 命令,而是使用jupyter

jupyter notebook --profile=myserver

使用the release of IPython 4.0,IPython 中与语言无关的部分(例如笔记本服务器)移至Jupyter。您可以在这些链接中阅读有关 The Big Splitthe new release of Jupyter 的更多信息。

【讨论】:

  • jupyter 实际上也不再有配置文件,请参见此处:github.com/jupyter/notebook/pull/310
  • @KevinDahl,嗯,那我想知道 OP 是什么意思,它解决了这个问题。我对它还不够熟悉。
猜你喜欢
  • 2014-12-01
  • 1970-01-01
  • 1970-01-01
  • 2012-08-27
  • 2017-01-17
  • 1970-01-01
  • 2014-01-31
  • 2013-09-24
  • 2011-09-24
相关资源
最近更新 更多