How to increase the ipython qtconsole scrollback buffer limit
Asked Answered
L

2

12

When I load ipython with any one of:

ipython qtconsole
ipython qtconsole --pylab
ipython qtconsole --pylab inline

The output buffer only holds the last 500 lines. To see this run:

for x in range(0, 501):
   ...:     print x

Is there a configuration option for this? I've tried adjusting --cache-size but this does not seem to make a difference.

Longish answered 6/2, 2013 at 2:48 Comment(0)
F
17

Quickly:

ipython qtconsole --IPythonWidget.buffer_size=1000

Or you can set it permanently by adding:

c.IPythonWidget.buffer_size=1000

in your ipython config file.

For discovering this sort of thing, a helpful trick is:

ipython qtconsole --help-all | grep PATTERN

For instance, you already had 'buffer', so:

$> ipython qtconsole --help-all | grep -C 3 buffer
...
--IPythonWidget.buffer_size=<Integer>
    Default: 500
    The maximum number of lines of text before truncation. Specifying a non-
    positive number disables text truncation (not recommended).

If IPython used a different name than you expect and that first search turned up nothing, then you could use 500, since you knew what the value was that you wanted to change, which would also find the relevant config.

Faggot answered 6/2, 2013 at 6:28 Comment(7)
Excellent. Every suggestion works. Thanks also for the algorithm to find other configuration options. Note that the configuration file -- which I thought contained all the defaults -- does not mention buffer_size.Longish
ipython_qtconsole_config.py would be the relevant one. It should be in there. If not, you might generate a fresh config ipython profile create fresh, and look in there.Faggot
I didn't have ipython_qtconsole_config.py . But now 'ipython profile create fresh' makes one. Hmm. Speculation: This may be because qtconsole was not originally functional in fedora 17. I had to manually 'pip-python install pygments' to get 'ipython qtconsole' to work. By that time I may have already created the profiles.Longish
yes, the qtconsole must be importable in order to generate the default config file.Faggot
I have set that number to 10,000 but it seems internally it cannot go back further than 1000 with history-search-backward. I open the sqlite file and it has commands from more than a year ago (53000 lines) but the history does no go back.Jody
This does not work with Jupyter QtConsole anymore and I cannot find the appropriate new settingsJody
For Jupyter QtConsole the config file is jupyter_qtconsole_config.py and the line you need to add is c.JupyterWidget.buffer_size=1000. Note that (on Windows at least) the config file is stored in the ~/.jupyter directory. I couldn't find a way to generate this config file so I just made an empty one.Vassalize
B
0

The accepted answer is no longer correct if you are using Jupyter. Instead, the command line option should be:

jupyter qtconsole --ConsoleWidget.buffer_size=5000

You can choose whatever value you want, just make it larger than the default of 500.

If you want to make this permanent, go to your home directory - C:\Users\username, /Users/username, or /home/username - then go into the .jupyter folder (create it if it doesn't exist), then create the file jupyter_qtconsole_config.py and open it up in your favorite editor. Add the following line:

c.ConsoleWidget.buffer_size=5000

Again, the number can be anything, just as long as it is an integer larger than 500. Don't worry that c isn't defined in this particular file, it is already defined elsewhere in the startup machinery.


Thanks to @firescape for the pointer in the right direction.

Burkhard answered 22/8, 2021 at 17:38 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.