How to detect if running ipython qtconsole? - ipython

The IPython notebook and Qt console both support displaying rich representations of objects. This is done by defining, for example, a _repr_html_ method.
The problem is that these two render the HTML differently. Is there a way for me to detect whether running under ipython qtconsole so that I can use a more basic set of HTML? Preferably a documented way that is not likely to break in the future?

I have a similar problem. Doing color in IPython terminal requires calling in to windows DLL's, but the color in qtconsole seems to support the linux based escape sequences....anyway. here's what I have found. Its ugly...but it will at least tell you terminal vs. qtconsole...Oh, and I haven't tried with the notebook:
import __main__
if hasattr(__main__,"get_ipython"):
import IPython.kernel.zmq.zmqshell as z
if isinstance(get_ipython(), z.ZMQInteractiveShell):
print 'yep...its qtconsole'

Related

PyPlot figure not shown in VS Code Jupyter "UserWarning: Matplotlib is currently using agg, which is a non-GUI backend, so cannot show the figure."

I run Julia inside Jupyter notebook within the Microsoft Visual Studio Code IDE.
When I try to make a PyPlot plot, the figure is not shown at and instead I am seeing the following message:
UserWarning: Matplotlib is currently using agg, which is a non-GUI backend, so cannot show the figure.
The figure will be shown when a PyPlot.display_figs() line will be added at the end of the cell code (note that the display_figs method is not exported so it needs be prepended with PyPlot).
Note that I observe this happening from time to time on some VS Code installation so I publish here this workaround so other people can easily google it.

Characters in an ncurses app showing correctly only in tmux

I have ported and cross-compiled the calcurse app to Blackberry 10 as part of the Berrymuch project (https://github.com/BerryFarm/berrymuch/tree/master/ports-wip/calcurse) however I am facing display issues with pseudo-graphical characters. When launched in the term48 terminal app (TERM=xterm-256color) the separators are displayed as letters.
broken output
However if the same app is started in tmux the separators appear fine.
ok output
I've tried running with TERM=screen in the terminal itself but that didn't solve the issue.
Does anyone have a theory where it might be going wrong?
I suspect either a) Buggy ncurses on bb10 b) Broken ncurses feature detection in the app c) Broken terminal feature detection d) locale information missing in the system
LC_ALL is set to en_US.UTF-8. Setting NCURSES_NO_UTF8_ACS=1 doesn't help either. ldd shows that calcurse is linked against libncursesw.so.1
I think you are on the right track with NCURSES_NO_UTF8_ACS - tmux will use UTF-8 for drawing the ACS by default if it thinks the terminal supports it (because your LANG contains UTF-8), so it sounds like your terminal supports UTF-8 but does not support ACS properly. Does the following work outside tmux (it should show symbols rather than ASCII):
tput enacs; tput smacs; tput acsc; tput rmacs; echo
Modern ncurses should also use UTF-8, I don't know why it is not. You might want to check what ncurses version you are using and perhaps try a newer one, there is also the U8 terminfo(5) capability, you could try a custom entry with that set to 0 or 1.

Does Enthought Canopy have an auto-complete and/or auto-suggest feature?

I am using the free version of Enthought Canopy for Python work and am forever finding myself hitting Ctrl + Space for an auto-complete list, but it never comes up.
It also doesn't auto-suggest anything whilst I type.
I have looked through all available settings and cannot find an option there to activate it.
Is this feature available and if so, how can one activate it?
Type the following:
import numpy as np
a = np.ar
Immediately after ar, press the Tab key. What do you see?
Reference in User guide:
http://docs.enthought.com/canopy/quick-start/code_editor.html#tab-completion

QUTIP output displayed as image in iPython console within Spyder

I have been having this issue for a while:
Using iPython console in Spyder 2.3.8, and installed QUTIP 3.1.0,
I tried to run a simple code:
qt.coherent(3,1)
where I was expecting the output to be displayed as an array.
However, doing so in iPython in Spyder it shows an image:
It seems for some reasons it rendered the array as image, and this is awkward to read in most cases, which I prefer to have the array displayed, which actually works if I use the Python3 console in Spyder.
May I know if you have any idea what the cause maybe?
The weird thing is that, this happens only to my Fedora Scientific 23, to the Spyder3 running Python3.4.
Another computer running Windows and WinPython didn't share the same problem, which the array got displayed correctly.
Thanks for your attention.
It seems that the ipython in spyder is calling the latex_repr method rather than just repr. Seems to be a bug somewhere in spyder as the standard ipython terminal has no such error.
The image printing problem appears when I automatically loaded SymPy which is done by: go to spyder Tools>>Prefeneces>>Ipython console>> Advance setting>> check or uncheck symbolic mathematic
When I check the symbolic mathematic, I generally get the result as an image, so I uncheck it and restart spyder, now it works well.
However, if you want to calculate something from symbolic math, it is better to check the "symbolic math" box again. I try to load sympy to ipython but I constantly get a typeerror.

Is there a way to access Stata from eclipse?

… similar to the StatET plugin that allows you to run R code from Eclipse?
I tried googling it but nothing useful has turned up.
None that I know. If you're a CLI junky or willing to use Emacs, you might find limited support through the ESS package and the ado-mode. This is what I used on Mac OS X when I want to run short snippet of code, or use Stata in batch mode, but there's no interactive graphical output (you can just save graphics as PDF as usual). The ado-mode provides basic syntax highlighting and can send region or buffer to a running instance of Stata GUI program (not the executable file, stata-*, that is being used by ESS).
Here are two screenshots of (top) edition of code in Emacs with the ado-mode, and (bottom) an interactive Stata session (no plot produced).
Some notes on text editors for Stata users provides a list of text editors that can be used with Stata (without interactive facilities, though).
There seems to be a promising project starting up here:
http://mas802.wordpress.com/2011/09/06/stata-plugin-for-eclipse-alpha/