本文介绍了我在哪里可以在 Jupyter 中放置启动脚本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找一种将我的启动脚本放入 Jupyter 的方法.在 IPython 中,我将它放在 $IPYTHON_DIR/profile_default/startup/ 下.

I'm looking for a way to put my startup script in Jupyter. In IPython, I put it under the $IPYTHON_DIR/profile_default/startup/.

在 Jupyter 中,配置文件似乎应该是 $JUPYTER_CONFIG_DIR/jupyter_notebook_config.py.但是,我想使用我的启动文件,该文件在内核启动时导入了大量 Python 库.

In Jupyter, it seems that the config file should be $JUPYTER_CONFIG_DIR/jupyter_notebook_config.py. However, I would like to use my startup file, which import a slew of Python libraries at the launch of the kernel.

我可以在 Jupyter 中放置这样的文件?

Where can I put such file in Jupyter?

推荐答案

在jupyter notebook中可以通过这个获取默认的启动脚本文件夹:

You can get the default startup script folder via this in jupyter notebook:

get_ipython().profile_dir.startup_dir

在我的 Windows PC 上,文件夹是:C:Usersmyusername.ipythonprofile_defaultstartup

On my Windows PC, the folder is: C:Usersmyusername.ipythonprofile_defaultstartup

并阅读文件夹下的README文件.

And do read the README file under the folder.

    Files will be run in lexicographical order, so you can control
the execution order of files with a prefix, e.g.::

    00-first.py
    50-middle.py
    99-last.ipy

所以你可以在文件夹下放一个名为00-xx.py的文件.

So you can put a file named 00-xx.py under the folder.

这篇关于我在哪里可以在 Jupyter 中放置启动脚本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-29 18:25