Skip to content

ZMQShell always uses default profile #939

Closed

Description

@takluyver

Starting the terminal client in Python 3 uses a python3 profile by default, so Python 3 commands are kept separate from the main sequence. Starting the Qt console or the HTML notebook, we get the 'default' (i.e. Python 2) profile.

Explicity calling for another profile, e.g. with ipython qtconsole --profile math fails in Python 2.7 as well.

Activity

  1. fperez commented on Oct 28, 2011

    @fperez
    Member

    From your priority rating, I'm assuming we can live with this for 0.12, right? If not, feel free to bump it up and milestone it, though I hope you won't :)

  2. takluyver commented on Oct 28, 2011

    @takluyver
    MemberAuthor

    It's not the end of the world, it just means that your input history from Python 2 and 3 get mixed.

    I think it should be a simple change somewhere that we're specifying the default profile. I'm having a look, but I can't immediately spot it. Who's most familiar with the Application framework?

  3. fperez commented on Oct 28, 2011

    @fperez
    Member

    On Fri, Oct 28, 2011 at 1:05 PM, Thomas
    reply@reply.github.com
    wrote:

    Who's most familiar with the Application framework?

    @minrk, I think.

  4. takluyver commented on Oct 28, 2011

    @takluyver
    MemberAuthor

    app.profile is getting set to Python 3, but it appears it's not being propagated to the shell instance.

  5. takluyver commented on Oct 28, 2011

    @takluyver
    MemberAuthor

    Quickly testing, it appears that the same thing happens if I start ipython qtconsole --profile pysh (with any profile name) in Python 2.7. I think this makes it a blocker.

  6. takluyver commented on Oct 28, 2011

    @takluyver
    MemberAuthor

    OK, I think I've found it. The terminal frontend initialises TerminalInteractiveShell by explicitly passing it a profile_dir argument. But the IPython kernel doesn't pass the equivalent argument when it instantiates the ZMQInteractiveShell.

    I don't know what the best way to deal with this is. The Application, which has the correct profile info, is a layer removed from the Shell (which needs that info) by the Kernel. Do we pass the information through the kernel, or change the profile dir after the shell has been instantiated?

  7. minrk commented on Oct 28, 2011

    @minrk
    Member

    I'm a bit confused by this, because it definitely is not true for me. I can start the qtconsole just fine, and both front and backend share the profile, no matter how or if I set it (python 2.7).

    Can you print sys.argv and get_ipython().config in the kernel?

    I cannot test the qtconsole with Python 3, because I don't have working pyqt on Python 3.

    Side note: I would actually argue that we should remove the different default profile behavior. I imagine that config that is not valid in both is relatively rare, and users with sufficiently complex config that it does conflict, who also regularly use IPython in both py3 and py2 (all 5 of them), should manually specify a different profile when they use IPython with the Python they use less.

    I would also rather not have my history separate for the two, because code that is not valid in both is rare, and I would much rather tweak the code that needs small adjustments from my history than retype it all over again.

    I think this made sense when py3k support was off in a testing branch, but now that it is in trunk we should stop doing it.

  8. minrk commented on Oct 28, 2011

    @minrk
    Member

    aha! I see what you mean by the shell having the wrong profile. The shell's profile attribute is not updated with the application's value in the zmq case (shell.profile is reported by %profile, not the Application value). I'm not sure that this attribute actually does much anymore, now that it is really an Application-level option, but it is a one-line fix. I'll push in a sec.

  9. minrk commented on Oct 28, 2011

    @minrk
    Member

    The shell really shouldn't need the profile info at all, but since the shell profile does exactly nothing in the zmqshell (as far as I can tell) other than feed the magic that tells you what the profile is, I think we can resolve this with two changes:

    1. add self.shell.profile_dir = self.profile_dir in IPKernelApp.init_shell()
    2. change magic_profile to query BaseIPythonApplication.instance() (error message if not initialized), instead of the shell object.
  10. takluyver commented on Oct 28, 2011

    @takluyver
    MemberAuthor

    Hmmm, but I think we load the history when the shell is instantiated, so it will attach to the default profile before we set the new profile_dir.

    I'm easygoing about whether we should have a separate profile for Python 3. The main difference for interactive use is print(). That's not a problem on a single line, because IPython treats print abc as an autocall. But it could be awkward for statements on multiple lines.

  11. fperez commented on Oct 28, 2011

    @fperez
    Member

    On Fri, Oct 28, 2011 at 2:54 PM, Thomas reply@reply.github.com wrote:

    I'm easygoing about whether we should have a separate profile for Python 3. The main difference for interactive use is print(). That's not a problem on a single line, because IPython treats print abc as an autocall. But it could be awkward for statements on multiple lines.

    I'm with Min on this one: I'd rather have the same history in both.

    Esp. b/c once I start using py3 for real, I'll add to my config from __future__ import print_function to have consistency on the print usage...

  12. takluyver commented on Nov 1, 2011

    @takluyver
    MemberAuthor

    @minrk: Did you get anywhere with fixing the original issue here?

  13. minrk commented on Nov 1, 2011

    @minrk
    Member

    Whoops - I thought you were working on it, but I now see my 'I'll push in a sec' comment. I'll put it together, it's quite simple.

  14. added 2 commits that reference this issue on Nov 3, 2014
    e294574
    109cf13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions