简体   繁体   English

如何在IPython / Jupyter笔记本中自动加载配置文件?

[英]How to automatically load profile in IPython/Jupyter notebooks?

In earlier versions of IPython it was possible to load a specific profile by 在早期版本的IPython中,可以通过以下方式加载特定的配置文件:

ipython notebook --profile=my_profile

so that I can include things like autoreload in my_profile. 这样我就可以在my_profile中包含诸如autoreload的内容。

Since using IPython 4.0.1 (Jupyter actually) I'm getting the 自从使用IPython 4.0.1 (实际上是Jupyter)以来,

[W 09:21:32.868 NotebookApp] Unrecognized alias: '--profile=my_profile', it will probably have no effect.

warning, and the profile is not loaded. 警告,并且未加载配置文件。 Have you come across a workaround? 您遇到解决方法了吗?

In Jupyter create a kernel for each profile. 在Jupyter中,为每个配置文件创建一个内核。

Find the kernels directory under the jupyter configuration directory {jupyter configuration}/kernels (on my Mac this is $HOME/Library/Jupyter/kernels ): 在jupyter配置目录{jupyter configuration}/kernels下找到内核目录(在我的Mac上是$HOME/Library/Jupyter/kernels ):

$ mkdir profile-x-kernel
$ cat << EOF > profile-x-kernel/kernel.json
{                                
    "display_name": "Profile X (Python 3)",
    "language": "python3",          
    "env": { },                              
    "argv": [ "python3", "-m", "ipykernel", "--profile", "profile_x", "-f", "{connection_file}" ]
}
EOF                          

Then you can select the kernel from the kernel menu in Jupyter, without having to restart the whole notebook server. 然后,您可以从Jupyter的内核菜单中选择内核,而不必重新启动整个笔记本服务器。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM