qtconsole ignores exec_lines #545

Closed
eteq opened this Issue Jun 30, 2011 · 5 comments

2 participants

@eteq

When I start a new qtconsole using a profile I've defined (or, for that matter, the default profile), the IPKernelApp.exec_lines configuration option seems to be ignored. Based on the behavior of the ipython_config.py TerminalIPythonApp.exec_lines option, I would have expected lines in the IPKernelApp.exec_lines list to be run when I start the qtconsole.

For example, if I add the following line to my ipython_qtconsole_config.py file:

 c.IPKernelApp.exec_lines = ['from __future__ import division']

and then run the qtconsole, inputting "1/2" still gives me "0" instead of the expected "0.5". On the other hand, if I execute "from future import division" by hand and then "1/2", "0.5" comes out.

@minrk
IPython member

This code definitely works for me.

@minrk
IPython member

Do you set any other exec_lines values in ipython_config? You can see the current config by printing get_ipython().config in the console.

@eteq

Starting using "ipython qtconsole", get_ipython().config shows me the following:

{'KernelApp': {'hb_port': 57786,
  'iopub_port': 57784,
  'ip': '127.0.0.1',
  'parent': 1,
  'shell_port': 57783,
  'stdin_port': 57785},
 'ProfileDir': {},
 'TerminalIPythonApp': {'exec_lines': ['from __future__ import division']},

'TerminalInteractiveShell': {'colors': 'Linux'}}

The 'TerminalIPythonApp' entry appears to be because I have "c.TerminalIPythonApp.exec_lines = ['from future import division']" in my ipython_config.py file for this profile. I can comment out this line, and it will disappear. Either way, though, I still get the 1/3=0 behavior...

@eteq

On a hunch, I pulled the latest master (apparently I was a few days behind), and rebuilt ipython. After trying again, this issue now seems to be resolved, so I guess it was very recently fixed.

Sorry for the noise!

@eteq eteq closed this Jun 30, 2011
@minrk
IPython member

Ah, you said it was in ipython_qtconsole_config.py. Yes, that was actually #544, and just closed today. It wasn't the specific configurable that was being ignored in the kernel, but the entire file, which was only loaded by the frontend.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment