如何从Jupyter 4.x获取IPython配置文件行为? [英] How do I get IPython profile behavior from Jupyter 4.x?

查看:96
本文介绍了如何从Jupyter 4.x获取IPython配置文件行为?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有官方(?)建议运行IPython Notebook服务器,并通过

There was official(?) recommendation of running an IPython Notebook server, and creating a profile via

$ ipython profile create nbserver

按照 http://ipython.org/ipython-doc/1/interactive/public_server.html 。通过 ipython notebook ipython notebook --profile = nbserver 。

使用Jupyter 4.0,有一个更改,不再有配置文件。我找到了对话 https://gitter.im/ipython/ipython/archives / 2015/05/29 有用户minrk说:

With Jupyter 4.0, there's a change and there are no longer profiles. I've found the conversation https://gitter.im/ipython/ipython/archives/2015/05/29 which has user minrk saying:


.ipython目录中有几个内容:

The .ipython directory has several things in it:

多个配置目录(称为配置文件)

multiple config directories (called profiles)

一个'data'目录,包含kernelspecs,nbextensions等内容

one 'data' directory, containing things like kernelspecs, nbextensions

运行时信息分散在各处,但主要是在配置文件中

runtime info scattered throughout, but mostly in profiles

Jupyter遵循更适合平台的约定:

Jupyter follows more platform-appropriate conventions:

JUPYTER_CONFIG_DIR的一个配置目录,默认:.jupyter

one config dir at JUPYTER_CONFIG_DIR, default: .jupyter

JUPYTER_DATA_DIR的一个数据目录,默认值:特定于平台

one data dir at JUPYTER_DATA_DIR, default: platform-specific

JUPYTER_RUNTIME_DIR的一个运行时目录,默认:特定于平台

one runtime dir at JUPYTER_RUNTIME_DIR, default: platform-specific

这是一个相当含糊的说法:

And a rather cryptic remark:


如果你想使用不同的配置,sp使用JUPYTER_CONFIG_DIR =以及

If you want to use different config, specify a different config directory with JUPYTER_CONFIG_DIR=whatever

获取不同的配置目录是什么是获得不同行为的最佳方式(例如,在作为服务器运行时与正常使用)?

What's the best way to get different behavior (say, between when running as a server vs normal usage)?

是否涉及运行类似:

$ export JUPYTER_CONFIG_DIR=~/.jupyter-nbserver
$ jupyter notebook

每当服务器'需要运行配置文件?和

whenever a server 'profile' needs to be run? and

$ export JUPYTER_CONFIG_DIR=~/.jupyter
$ jupyter notebook

每当普通配置文件需要运行时?因为这看起来很可怕。在Jupyter 4.0中执行此操作的最佳方法是什么?

whenever a 'normal' profile needs to run? Because that seems terrible. What's the best way to do this in Jupyter 4.0?

推荐答案

使用此博客文章中的一些代码 http://www.svds.com/jupyter-notebook-best-practices-for-数据科学/ 并更新它。最简单的解决方案似乎是创建别名,例如:

Using some code from this blog post http://www.svds.com/jupyter-notebook-best-practices-for-data-science/ and updating it. The easiest solution appears to be to create an alias, like:

alias jupyter-nbserver='JUPYTER_CONFIG_DIR=~/.jupyter-nbserver jupyter notebook'

所以现在你可以通过简单的命令运行带有不同配置的jupyter笔记本code> jupyter-NBSERVER

So now you can run the jupyter notebook with a different config via the simple command jupyter-nbserver.

一个更强大的解决方案可能涉及创建一个改变环境变量的bash函数,检查是否有配置文件,如果没有创建一个,然后执行,但这可能是矫枉过正。我在这个相关问题上给出的答案 https://stackoverflow.com/a/32516200/246856 进入创建新配置文件的初始配置文件。

A more robust solution might involve creating a bash function that changes the environment variable, checks whether there's a config file, if not creating one, then executing, but that's probably overkill. The answer that I give on this related question https://stackoverflow.com/a/32516200/246856 goes into creating the initial config files for a new 'profile'.

这篇关于如何从Jupyter 4.x获取IPython配置文件行为?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆