PyROOT Breaks Python Prompt

Hi all,

I am having a weird problem with PyROOT. When I do “import ROOT” inside python, the prompt breaks. For example, I am not able to use the backspace key to remove text. Also using arrows to navigate the current command does not do anything.

Some info about my setup:

  • Gentoo Linux
  • Python 3.4.5
  • ROOT 6-06-06 compiled using CMake

Any idea what could be wrong? Any settings I should double-check when compiling ROOT?

I don’t think it is Python 3, because I have another computer where PyROOT works fine.

I am also getting this on OSX, using MacPorts to install both ROOT and Python.

The problem also occurs in ipython. Also, after encountering the problem and exiting python, the OSX Terminal is messed up and needs to be “stty sane”.

Versions:
OSX: 10.11.6
MacPorts: 2.3.4
ROOT: 6.06/06
python: 2.7.12
ipython: 4.2.0
OSX Terminal: 2.6.1 (361.1)

I think there is a problem with my readline library that is causing this. I just upgraded to ipython 5.0, which dumped readline in favour of prompt_toolkit. Now ipython works without issues. Regular python still does not.

Hi,

yes, is readline (through ncurses, that is). Has some odd interaction with LLVM. I’ve had this for years on SuSE, but never understood it. Nor was I able to fix it: it’s one of those libraries that are hard to replace.

With MacPorts, I’ve had the problem as well, but in my case it was unrelated to ROOT: all python sessions messed up the terminal. The issue was setting MacPorts envars in .zshenv, rather than .zshrc. The login order runs the former first, then system zsh setup, then .zshrc last. The net effect was a mixture of orderings in /usr, /usr/local, and /opt/local, with different orderings between PATH and LD_LIBRARY_PATH. Fixing the orderings (by putting all in .zshrc, which then overrode any system changes) made the problem go away.

Cheers,
Wim

The solution to the problem of needing “stty sane” when exiting from even a normal python prompt (on OSX 10.11) is to install python27 +readline from MacPorts. This makes it use a macports-provided readline instead of the fake one provided by OSX.

After making this change, ipython 5.1 still does not let me show ROOT windows, while the older ipython (4.2) still works.