Problems with pyroot on macOS 10.14.2 with ROOT 6.16/00 and python 2.7.15_2 from brew

Hello,

I’ve been happily using ROOT through brew for some time on my mac, but recently PyROOT broke. I’m not exactly sure, and I may very well have been fiddling with other packages installed by brew to provoke it. I used to get a segfault (sorry, didn’t keep the log…) but after uninstalling ROOT and reinstalling 6.16/00 I get a python error instead:

eduroam-10-200-21-94:~/Desktop/X0 > python
Python 2.7.15 (default, Jan 12 2019, 21:07:57) 
[GCC 4.2.1 Compatible Apple LLVM 10.0.0 (clang-1000.11.45.5)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import ROOT
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/Cellar/root/6.16.00/lib/root/ROOT.py", line 24, in <module>
    import cppyy
  File "/usr/local/Cellar/root/6.16.00/lib/root/cppyy.py", line 61, in <module>
    import libPyROOT as _backend
ImportError: dynamic module does not define init function (initlibPyROOT)
>>> 

It seems brew is quite happy with both the installation of ROOT and python (see below), and I don’t see any related issues/warnings from brew doctor. Any ideas how I can fix this?

Best,
Christian

eduroam-10-200-21-94:~/Desktop/X0 > brew info root
root: stable 6.16.00 (bottled), HEAD
Object oriented framework for large scale data analysis
https://root.cern.ch/
/usr/local/Cellar/root/6.16.00 (5,384 files, 291MB) *
  Poured from bottle on 2019-01-28 at 15:29:47
From: https://github.com/Homebrew/homebrew-core/blob/master/Formula/root.rb
==> Dependencies
Build: cmake ✔
Required: davix ✔, fftw ✔, gcc ✔, graphviz ✔, gsl ✔, libxml2 ✔, lz4 ✔, openssl ✔, pcre ✔, python ✔, tbb ✔, xrootd ✔, xz ✔
==> Options
--HEAD
	Install HEAD version
==> Caveats
Because ROOT depends on several installation-dependent
environment variables to function properly, you should
add the following commands to your shell initialization
script (.bashrc/.profile/etc.), or call them directly
before using ROOT.

For bash users:
  . /usr/local/bin/thisroot.sh
For zsh users:
  pushd /usr/local >/dev/null; . bin/thisroot.sh; popd >/dev/null
For csh/tcsh users:
  source /usr/local/bin/thisroot.csh

Emacs Lisp files have been installed to:
  /usr/local/share/emacs/site-lisp/root
==> Analytics
install: 817 (30 days), 2,422 (90 days), 11,168 (365 days)
install_on_request: 761 (30 days), 2,266 (90 days), 10,217 (365 days)
build_error: 0 (30 days)
eduroam-10-200-21-94:~/Desktop/X0 > brew info python@2
python@2: stable 2.7.15 (bottled), HEAD
Interpreted, interactive, object-oriented programming language
https://www.python.org/
/usr/local/Cellar/python@2/2.7.15_2 (4,750 files, 83.8MB) *
  Poured from bottle on 2019-01-21 at 23:48:42
From: https://github.com/Homebrew/homebrew-core/blob/master/Formula/python@2.rb
==> Dependencies
Build: pkg-config ✔, sphinx-doc ✘
Required: gdbm ✔, openssl ✔, readline ✔, sqlite ✔
==> Options
--HEAD
	Install HEAD version
==> Caveats
Pip and setuptools have been installed. To update them
  pip install --upgrade pip setuptools

You can install Python packages with
  pip install <package>

They will install into the site-package directory
  /usr/local/lib/python2.7/site-packages

See: https://docs.brew.sh/Homebrew-and-Python
==> Analytics
install: 175,940 (30 days), 429,498 (90 days), 2,114,588 (365 days)
install_on_request: 44,877 (30 days), 99,379 (90 days), 424,377 (365 days)
build_error: 0 (30 days)

ROOT Version: 6.16/00
Platform: Not macOS 10.14.2
Compiler: Not Apple LLVM version 10.0.0 (clang-1000.11.45.5)


ROOT from Homebrew is compiled by default for Python 3.x if I’m not mistaken, so you have to use that Python with ROOT. Try PYTHONPATH=/usr/local/lib/root python3 -c 'import ROOT'. That should work. You need to install ROOT with brew install root --without-python --with-python@2 to have ROOT for Python 2.x with Homebrew.

1 Like

Thanks for the hint! Indeed I might in the past have done something like that, and perhaps subsequent upgrades would have kept that option alive (and I forgot about it). Then when I uninstalled and reinstalled, it was lost.

But it seems like it doesn’t quite work like that (anymore?):

eduroam-10-200-21-94:~/Desktop/X0 > brew uninstall root
Uninstalling /usr/local/Cellar/root/6.16.00... (5,384 files, 291MB)
eduroam-10-200-21-94:~/Desktop/X0 > brew install root --without-python --with-python@2
Updating Homebrew...
==> Auto-updated Homebrew!
Updated 1 tap (homebrew/cask).
No changes to formulae.

Warning: root: this formula has no --with-python@2 option so it will be ignored!
Warning: root: this formula has no --without-python option so it will be ignored!
==> Downloading https://homebrew.bintray.com/bottles/root-6.16.00.mojave.bottle.tar.gz
Already downloaded: /Users/cohm/Library/Caches/Homebrew/downloads/94a249e8d6ceef2f02245e8f66a82fb1546b8579b317cf6608108b151f9b2897--root-6.16.00.mojave.bottle.tar.gz
==> Pouring root-6.16.00.mojave.bottle.tar.gz
Warning: root dependency gcc was built with a different C++ standard
library (libstdc++ from clang). This may cause problems at runtime.
==> Caveats
Because ROOT depends on several installation-dependent
environment variables to function properly, you should
add the following commands to your shell initialization
script (.bashrc/.profile/etc.), or call them directly
before using ROOT.

For bash users:
  . /usr/local/bin/thisroot.sh
For zsh users:
  pushd /usr/local >/dev/null; . bin/thisroot.sh; popd >/dev/null
For csh/tcsh users:
  source /usr/local/bin/thisroot.csh

Emacs Lisp files have been installed to:
  /usr/local/share/emacs/site-lisp/root
==> Summary
🍺  /usr/local/Cellar/root/6.16.00: 5,382 files, 291MB
eduroam-10-200-21-94:~/Desktop/X0 > python 
Python 2.7.15 (default, Jan 12 2019, 21:07:57) 
[GCC 4.2.1 Compatible Apple LLVM 10.0.0 (clang-1000.11.45.5)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import ROOT
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/Cellar/root/6.16.00/lib/root/ROOT.py", line 24, in <module>
    import cppyy
  File "/usr/local/Cellar/root/6.16.00/lib/root/cppyy.py", line 61, in <module>
    import libPyROOT as _backend
ImportError: dynamic module does not define init function (initlibPyROOT)
>>> 

Best,
Christian

Hmm, I don’t see any python2 mentions in the formula:

The tests works well on my machine, but there’s only one using python3:

eduroam-10-200-21-94:~/Desktop/X0 > brew test root
Testing root
==> /bin/bash test.bash
==> python3 -c import ROOT

I wonder if this support went away? The stats at https://formulae.brew.sh/formula/root show that the command you listed has been used quite a bit in the past, so it was a thing at some point.

Best,
Christian

Any more thoughts on this one? I could try to convert all my scripts to python 3 and future-proof them, I guess, but I don’t know if everyone I might collaborate with writing scripts I want to use locally for plotting etc will do the same.

The solution would otherwise be building from source, but that’s an hour of ROOT downtime every time there’s a new production release - so I really like the brew way since the updates were so quick and smooth!

Best,
Christian

There are new efforts to make ROOT available via conda (in the conda-forge channel). You could try that.
There is a dedicated channel for it on our Mattermost now, and you can find instructions on how to install it on Macs here. After you install, just run conda config --add channels conda-forge, and run conda install root. Maybe that helps. If you have access to CVMFS, you could also use one of the LCG releases. CVMFS is quite easy to install on Macs.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.