No Windows appearing on Mac using ipython

Hi,
I tried to get pyROOT running on my new computer and failed to get it working properly.
When i use python everything seems to work fine, but when i switch to ipython i run into troubles:
I can import ROOT and do all the bash stuff, but when i try to show a window (i.e. a TBrowser) the python/ROOT/X Window is open but does not display anything.
As soon as I close ipython (exit), the window actually appears for a very short time but of course is directly closed again.
I checked ROOT.gROOT.IsBatch() this is False.

I have the following configuration:
OS X 10.11.6 El Capitan
XQUartz 2.7.9
Macports version 2.3.4
used to install Python 2.7.12
downloaded sources for ROOT 6.06/06 and compiled from scratch using cmake

Does any one has an idea what could be the reason?

Cheers
veloxid

Can you post one of these examples not displaying any graphics ?

I am having the same issue. If I use the older version of ipython (4.2) it works fine, but the latest version (5.1 now) just freezes when I try to create a window.

I see the same issue, using OS X 10.11.6, ROOT 6.06/09 with Python 2.7.12 and ipython 5.1:

This works, no problem:

code > python
Python 2.7.12 (default, Sep 28 2016, 18:41:32)
[GCC 4.2.1 Compatible Apple LLVM 8.0.0 (clang-800.0.38)] on darwin
Type “help”, “copyright”, “credits” or “license” for more information.

import ROOT as R
h = R.TH1F(“h”,“hist”,100,0,10)
h.Draw()
Info in TCanvas::MakeDefCanvas: created default TCanvas with name c1
[/code]

This does not create a window, until you quit ipython, at which point a blank window appears briefly:

(P) > ipython
Python 2.7.12 (default, Sep 28 2016, 18:41:32) 
Type "copyright", "credits" or "license" for more information.

IPython 5.1.0 -- An enhanced Interactive Python.
?         -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help      -> Python's own help system.
object?   -> Details about 'object', use 'object??' for extra details.

In [1]: import ROOT as R
In [2]: h = R.TH1F("h","hist",100,0,10)
In [3]: h.Draw()
Info in <TCanvas::MakeDefCanvas>:  created default TCanvas with name c1

Right after the h.Draw() command I get a spinning beach ball for a while.
Is there any clue on this?

Hi,

there’s some code in ROOT.py affecting GUI events that is tailored specifically to IPython 5: if _is_ipython and 'IPython' in sys.modules and sys.modules['IPython'].version_info[0] >= 5 : from IPython.terminal import pt_inputhooks def _inputhook(context): while not context.input_is_ready(): _root.gSystem.ProcessEvents() pt_inputhooks.register('ROOT',_inputhook) get_ipython().run_line_magic('gui', 'ROOT')
I don’t recognize that code, so I suggest to ask its author …

Cheers,
Wim

I see this bug on Mac as well.

In ipython 5.1.0:

import ROOT
a = ROOT.TCanvas()

produces no TCanvas, but it briefly blinks on the screen when exiting ipython. The canvas appears no problem using the plain old python prompt (version 2.7.12 for me).

Worse still, if you do :

ipython --pylab

trying to make a TCanvas segfaults with the below message, and completely bricks your terminal session:

 *** Break *** segmentation violation
 Generating stack trace...
 0x000000010ff7624b in TClass::GetClass(char const*, bool, bool) (in libCore.so) (TClass.cxx:5429)
 0x000000010ff9d0d5 in TProtoClass::FillTClass(TClass*) (in libCore.so) (TInterpreter.h:103)
 0x000000010ff790ca in TClass::Init(char const*, short, std::type_info const*, TVirtualIsAProxy*, char const*, char const*, int, int, ClassInfo_t*, bool) (in libCore.so) (TClass.cxx
 0x000000010ff7a99a in TClass::TClass(char const*, short, std::type_info const&, TVirtualIsAProxy*, char const*, char const*, int, int, bool) (in libCore.so) (TClass.cxx:1276)
 0x00000001252f0e13 in ROOT::Internal::TQObjectInitBehavior::CreateClass(char const*, short, std::type_info const&, TVirtualIsAProxy*, char const*, char const*, int, int) const (in 
 0x000000010ff91169 in ROOT::TGenericClassInfo::GetClass() (in libCore.so) (TGenericClassInfo.cxx:207)
 0x00000001252f0465 in TGHtml::Dictionary() (in libGuiHtml.so) (atomic:842)
 0x000000010ff76138 in TClass::GetClass(char const*, bool, bool) (in libCore.so) (TClass.cxx:5405)
 0x000000010ff82be8 in TClass::InheritsFrom(char const*) const (in libCore.so) (TClass.cxx:4582)
 0x000000012160c9e5 in -[QuartzView drawRect:] (in libGCocoa.so) (QuartzWindow.mm:2724)
 0x00007fff8aa65cd2 in -[NSView _drawRect:clip:] (in AppKit) + 3626
 0x00007fff8aabdcad in -[NSView _recursiveDisplayAllDirtyWithLockFocus:visRect:] (in AppKit) + 1873
 0x00007fff8aabe08a in -[NSView _recursiveDisplayAllDirtyWithLockFocus:visRect:] (in AppKit) + 2862
 0x00007fff8aa633fb in -[NSView _recursiveDisplayRectIfNeededIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:topView:] (in AppKit) + 838
 0x00007fff8aa62be0 in -[NSThemeFrame _recursiveDisplayRectIfNeededIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:topView:] (in AppKit) + 334
 0x00007fff8aa60feb in -[NSView _displayRectIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:] (in AppKit) + 2449
 0x00007fff8aa5c3f5 in -[NSView displayIfNeeded] (in AppKit) + 1950
 0x00007fff8aa5bc3c in -[NSWindow displayIfNeeded] (in AppKit) + 232
 0x00007fff8b0e041b in ___NSWindowGetDisplayCycleObserver_block_invoke6365 (in AppKit) + 476
 0x00007fff8aa5b5d6 in __37+[NSDisplayCycle currentDisplayCycle]_block_invoke (in AppKit) + 941
 0x00007fff89aeaf71 in CA::Transaction::run_commit_handlers(CATransactionPhase) (in QuartzCore) + 85
 0x00007fff89aea42c in CA::Context::commit_transaction(CA::Transaction*) (in QuartzCore) + 160
 0x00007fff89aea0ec in CA::Transaction::commit() (in QuartzCore) + 508
 0x00007fff89af5977 in CA::Transaction::observer_callback(__CFRunLoopObserver*, unsigned long, void*) (in QuartzCore) + 71
 0x00007fff9bb04067 in __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ (in CoreFoundation) + 23
 0x00007fff9bb03fd7 in __CFRunLoopDoObservers (in CoreFoundation) + 391
 0x00007fff9bae2ef8 in CFRunLoopRunSpecific (in CoreFoundation) + 328
 0x00007fff89cd9935 in RunCurrentEventLoopInMode (in HIToolbox) + 235
 0x00007fff89cd9677 in ReceiveNextEventCommon (in HIToolbox) + 184
 0x00007fff89cd95af in _BlockUntilNextEventMatchingListInModeWithFilter (in HIToolbox) + 71
 0x00007fff8a903df6 in _DPSNextEvent (in AppKit) + 1067
 0x00007fff8a903226 in -[NSApplication _nextEventMatchingEventMask:untilDate:inMode:dequeue:] (in AppKit) + 454
 0x00007fff8a8f7d80 in -[NSApplication run] (in AppKit) + 682
 0x000000010a849637 in ffi_call_unix64 (in _ctypes.so) + 79
 0x00007fff5623ce00 in <unknown function>

For the moment, pyROOT is quite unusable…

Wim, thank you for the reply.

Digging a little deeper, here’s what I found:

[ol]
[li] If you switch to ipython 4.2, the problem goes away. This is probably the easiest solution. Just go “pip uninstall ipython”, followed by “pip install ipython=4.2” and all will be fine. I tested this with ROOT 6.06 and both python 2.7 and python 3.5[/li]
[li] The problem is mostly resolved in the current ROOT 6.09 aka “master” (commit 0cfb432cc4756f75cf523bda4e4a73ad6adc795f). The code Wim quotes was entered by Pere Mateo, and there are some additional changes by Wim. [/li]
[li] The only difference I see now between ipython 4.2 and ipython 5.1 now is that for ipython 5.1 you need to follow a Draw() command with an Update() command for the TCanvas you are drawing to, i.e. “c1 = R.gROOT.FindObject(“c1”), c1.Update()” will draw the contents. I also tested this with “ipython --pylab” and it works the same way.[/li][/ol]

So I think it is fixed now.

1 Like

Thanks for checking again. Yes, the problem is fixed in the master and in the release candidate v6-08-00-rc1

it sounds crazy but true, the pyroot does not display any canvas with ipython version higher than 5.0.0. One does not need to switch to the buggy ipython 4.2.0 to get pyroot working properly, to my experience the pyroot still behaves good with ipython 5.0.0!

I guess @etejedor can help you with this.

To me this is a known long standing problem.
On my Ubuntu 14.04 / x86_64, ROOT (plus Python 2.7.6) had problems with ipython 5.x so I installed ipython 4.x using: sudo pip install 'ipython[all]<5'

I am also using Ubuntu 14.04 x86_64, Python 2.7 and IPython 5.5.0 and the canvas shows correctly. @mato reported this problem to be fixed in ROOT 6.08.