ipython的历史文件在哪里

2024-05-29 03:11:21 发布

您现在位置:Python中文网/ 问答频道 /正文

我无法确定ipython在哪里存储它的历史。

a.没有~/。Python历史:

12:49:00/dashboards $ll ~/.py*
ls: /Users/steve/.py*: No such file or directory

b.python启动文件中没有特殊内容:

12:49:07/dashboards $echo $PYTHONSTARTUP
/shared/.pythonstartup
12:49:43/dashboards $cat /shared/.pythonstartup
import rlcompleter
import readline

readline.parse_and_bind("tab: complete")

但是:当我启动ipython的时候,我确实有很多可用的历史记录。

那么历史在哪里被保存?

更新来自@Stefano的答案指向了正确的方向:这里是实际路径

13:30:05/shared $ll ~/.ipython/profile_default/history.sqlite
-rw-r--r--  1 steve  staff  372736 Jun  3 12:48 /Users/steve/.ipython/profile_default/history.sqlite

Tags: pyimportdefaultsqlitereadlineipython历史profile
2条回答

如果您希望您的IPython历史记录是纯文本文件,您可以自己导出它。

%history -g -f filename 

IPython历史记录存储在profile目录中的SQLite数据库中。默认情况下:

~/.ipython/profile_default/history.sqlite

旧版本(1.x)将配置文件数据存储在~/.config/ipython中,至少在符合XDG basedir specs的平台上(即大多数Linux发行版)。

无论如何,您可以使用以下命令查找配置文件目录:

$ ipython locate profile default

注意,历史数据库是在IPython和IPython3之间共享的,如果两者都已安装。

相关问题 更多 >

    热门问题