gpt4 book ai didi

IPython:启动时自动加载扩展

转载 作者:行者123 更新时间:2023-12-02 10:17:50 24 4
gpt4 key购买 nike

在 IPython 中,我可以使用简单的命令加载自定义扩展:

%load_ext physics

这将加载文件~/.ipython/extensions/physical.py

如何告诉 IPython 在启动时自动加载扩展?

我已将该行添加到 /.ipython/profile_default/startup/import.py,但这不起作用:

from numpy import *

%load_ext physics

当我启动 IPython 时,出现以下错误:

File "~/.ipython/profile_default/startup/import.py", line 17
%load_ext physics
^
SyntaxError: invalid syntax

最佳答案

来自IPython documentation :

Using extensions

To load an extension while IPython is running, use the %load_ext magic:

In [1]: %load_ext myextension

To load it each time IPython starts, list it in your configuration file:

c.InteractiveShellApp.extensions = [
'myextension'
]

希望有帮助

关于IPython:启动时自动加载扩展,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31872520/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com