简体   繁体   English

ipython的历史文件在哪里

[英]Where is the history file for ipython

I can not determine where the ipython is storing its history. 我无法确定ipython存储历史的位置。

a. 一种。 There is no ~/.pythonhistory: 没有〜/ .pythonhistory:

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

b. Nothing special in the python startup file: 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")

c. C。 BUT: i do have plenty of history available in ipython when I start it up. 但是:当我启动ipython时,我确实有很多历史可用。

So where is that history being stored? 那么历史存储在哪里?

UPDATE the answer from @Stefano led the correct way: here is the actual path 更新 @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

如果您希望将IPython历史记录保存在纯文本文件中,则可以自行导出。

%history -g -f filename 

IPython history is stored in a SQLite database located in the profile directory. IPython历史记录存储在位于配置文件目录中的SQLite数据库中。 By default: 默认:

~/.ipython/profile_default/history.sqlite

Older versions (1.x) stored profile data in ~/.config/ipython , at least on platforms conforming to XDG basedir specs (ie most Linux distributions). 旧版本(1.x)在~/.config/ipython存储了配置文件数据,至少在符合基于XDG的规范 (即大多数Linux发行版)的平台上。

Anyway, you can locate the profile directory with: 无论如何,您可以找到配置文件目录:

$ ipython locate profile default

Notice that the history database is shared between IPython and IPython3, if both are installed. 请注意,历史数据库在IPython和IPython3之间共享(如果两者都已安装)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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