IPython startup script: Check if QtConsole

Jeronimo

For my IPython QtConsole, I have a startup script in my profile_default/startup folder, which contains the following lines:

ipy = get_ipython()

try:
    plot
except NameError:  #  not loaded yet
    ipy.run_line_magic("pylab", "inline")

This works fine in the QtConsole and Notebook, but if I now run ipython with no subcommand, i.e. in the Windows command line, it prints an error that the 'inline' GUI is invalid.

Is there any way I can check for the subcommand (qtconsole, notebook or "None") inside the startup script, so I can avoid that message?

(IPython QtConsole 3.2.0, WinPython-64bit-3.4.3.4)

Matt

I'm going to assume that ipy is the result of get_ipython().

Warning: You should not try to have code that behave differently on various frontend. It will break at some point, and lead to hard to debug issues that don't make sens. Nasal demons will be on a the lookout for the smallest misstep to haunt you.

That being say, in the pure, classical terminal IPython you can can verify that:

In [1]: type(get_ipython())
Out[1]: IPython.terminal.interactiveshell.TerminalInteractiveShell

Which is not true for Notebook and QtConsole (which are ZMQInteractiveShell). In both case IPython.terminal.interactiveshell.TerminalInteractiveShell should be importable, and you can check with issubclass in which case you are.

Now, you can also create your own aliases on windows (not sure how), that pass extra command line arguments to IPython, in order for notebook and qtconsole to not have the same startup sequence.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Start ipython qtconsole as interactive interpreter after script execution

From Dev

Start ipython qtconsole as interactive interpreter after script execution

From Dev

Anaconda ipython qtconsole launcher

From Dev

ipython Qtconsole - conflicting keybinding

From Dev

Error loading ipython qtconsole

From Dev

Why is IPython QtConsole not launching?

From Dev

Displaying an Image in the iPython qtconsole

From Dev

IPython QtConsole: select text to copy?

From Dev

embedding ipython qtconsole and passing objects

From Dev

Launch ipython qtconsole on a specific environnement

From Dev

Failed to change font size in ipython qtconsole

From Dev

Enabling vi key bindings in IPython qtconsole

From Dev

How do I print without truncation in ipython qtconsole?

From Dev

How to turn on auto-complete of brackets in ipython qtconsole

From Dev

What is the correct syntax for launching ipython qtconsole/notebook for python version=x

From Dev

Strange bug when typing import copy in iPython-QtConsole (Anaconda)

From Dev

Enable Gnome/GTK integration of IPython qtconsole from Anaconda

From Dev

Can't quit PyQt5 application with embedded iPython Qtconsole

From Dev

Enthought Canopy & IPython QtConsole ignore logging.basicConfig

From Dev

Python logging module: duplicated console output [IPython Notebook/Qtconsole]

From Dev

Getting Ipython QtConsole's current config infomation in it's interactive shell

From Dev

What is the correct syntax for launching ipython qtconsole/notebook for python version=x

From Dev

How to create a startscript for ipython qtconsole in windows7?

From Dev

ipython notebook startup file

From Dev

ipython notebook startup file

From Dev

ipython startup config for spyder IDE

From Dev

How can I remove borders from display of dataframe in iPython QtConsole (Anaconda)?

From Dev

How do I start ipython's qtconsole cleanly on Win7

From Dev

Qt programs (Canopy GUI, ipython qtconsole) crash in Enthought Canopy Win7 64Bits

Related Related

  1. 1

    Start ipython qtconsole as interactive interpreter after script execution

  2. 2

    Start ipython qtconsole as interactive interpreter after script execution

  3. 3

    Anaconda ipython qtconsole launcher

  4. 4

    ipython Qtconsole - conflicting keybinding

  5. 5

    Error loading ipython qtconsole

  6. 6

    Why is IPython QtConsole not launching?

  7. 7

    Displaying an Image in the iPython qtconsole

  8. 8

    IPython QtConsole: select text to copy?

  9. 9

    embedding ipython qtconsole and passing objects

  10. 10

    Launch ipython qtconsole on a specific environnement

  11. 11

    Failed to change font size in ipython qtconsole

  12. 12

    Enabling vi key bindings in IPython qtconsole

  13. 13

    How do I print without truncation in ipython qtconsole?

  14. 14

    How to turn on auto-complete of brackets in ipython qtconsole

  15. 15

    What is the correct syntax for launching ipython qtconsole/notebook for python version=x

  16. 16

    Strange bug when typing import copy in iPython-QtConsole (Anaconda)

  17. 17

    Enable Gnome/GTK integration of IPython qtconsole from Anaconda

  18. 18

    Can't quit PyQt5 application with embedded iPython Qtconsole

  19. 19

    Enthought Canopy & IPython QtConsole ignore logging.basicConfig

  20. 20

    Python logging module: duplicated console output [IPython Notebook/Qtconsole]

  21. 21

    Getting Ipython QtConsole's current config infomation in it's interactive shell

  22. 22

    What is the correct syntax for launching ipython qtconsole/notebook for python version=x

  23. 23

    How to create a startscript for ipython qtconsole in windows7?

  24. 24

    ipython notebook startup file

  25. 25

    ipython notebook startup file

  26. 26

    ipython startup config for spyder IDE

  27. 27

    How can I remove borders from display of dataframe in iPython QtConsole (Anaconda)?

  28. 28

    How do I start ipython's qtconsole cleanly on Win7

  29. 29

    Qt programs (Canopy GUI, ipython qtconsole) crash in Enthought Canopy Win7 64Bits

HotTag

Archive