0

我的 ipython 配置文件没有被 django_extensions 的 shell_plus 加载。

我的 ipython 配置文件包含:

c.InteractiveShellApp.exec_lines = ['aa=5',]

测试它:

(virtualenv) $ ipython
>>>  ....
In [1]: aa
Out[1]: 5

作品。现在,测试通过 django_extensions 调用的 ipython:

(virtualenv) $ python manage.py shell_plus

这让我进入 ipython(突出显示作品,%run 作品等),但没有加载我的配置:

In [1]:aa
NameError: name 'aa' is not defined

我怎样才能让它工作?

4

1 回答 1

2

这是因为 shell_plus.py 使用IPython.embedIPython.start_ipython启动 shell。Embed 不会加载您的配置文件。更改代码或使用 SHELL_PLUS_PRE_IMPORTS 之类的内容来加载您想要的内容。

于 2014-03-26T09:41:07.153 回答