简体   繁体   中英

How to create a project specific startup script for ipython

我能够找到很多关于如何在“IPYTHONDIR”中提供配置文件的文档,但我希望将所有与项目相关的文件都放在项目目录中,这样我的 ipython 配置就在同一个 git repo 中管理与其他用户共享项目时不需要额外的步骤。

The best way to do this would be to create a .ipython directory in your project directory. You can do this as:

$ mkdir /path/to/project/.ipython

You should then generate default configuration files in this directory as:

$ ipython profile create my_config_name --ipython-dir /path/to/project/.ipython

Now you can edit these default config files as you desire for this project.

Then, we'll need to instruct iPython on where to look to find these config files. To do so we will alter the IPYTHONDIR environment variable. This is as simple as:

$ export IPYTHONDIR=/path/to/project/.ipython

With this, iPython will now use the configuration files you've set for this project.

If you're sharing the project with other users you could always put the above export command in a little shell script, say, set_ipy.sh , to make things even easier. Just ensure that the script is sourced ( source set_ipy.sh ) and not run as ./set_ipy.sh , otherwise the IPYTHONDIR environment variable will not be altered for the current shell.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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