# Pyroot broken in brew again

**URL:** <https://root-forum.cern.ch/t/pyroot-broken-in-brew-again/44684>\
**Category:** ROOT\
**Created:** [May 3, 2021, 1:08am UTC](https://root-forum.cern.ch/t/pyroot-broken-in-brew-again/44684 "2021-05-03T01:08:14Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![jasondet](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/jasondet/32/25854_2.png) [@jasondet](https://root-forum.cern.ch/u/jasondet)\
**Post date:** [May 3, 2021, 1:08am UTC](https://root-forum.cern.ch/t/pyroot-broken-in-brew-again/44684/1 "2021-05-03T01:08:14Z")

</div>

* * *

_ROOT Version:_ v6-22-08  
_Platform:_ Mac OS X 11.3  
_Compiler:_ clang 12.0.0 (root installed via brew)

* * *

I’m trying to import root in python after installing via brew.

First I got warnings about cppyy missing. This went away with “pip install cppy”.

Then I ran into this error:

> [@Cannot import ROOT 6.22 in Python 3.9.1 "could not load cppyy\_backend library"](https://root-forum.cern.ch/t/cannot-import-root-6-22-in-python-3-9-1-could-not-load-cppyy-backend-library/43764):
>
> Hi all. I just installed ROOT using Homebrew and I cannot import it in python3, getting the following error: '\>\>\> import ROOT Traceback (most recent call last): File “”, line 1, in File “/usr/local/Cellar/root/6.22.06\_2/lib/root/ROOT/init.py”, line 22, in import cppyy File “/usr/local/Cellar/root/6.22.06\_2/lib/root/cppyy/init.py”, line 131, in from .\_cpython\_cppyy import \* File “/usr/local/Cellar/root/6.22.06\_2/lib/root/cppyy/\_cpython\_cppyy.py”, line 18, in c = loader.load\_cpp\_bac…

I fixed it with the env var recommended by Axel in that post (updating the path to point to the appropriate file on my system).

But pyroot still doesn’t load. Importing anything from ROOT within python gives:

```auto
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/Cellar/root/6.22.08/lib/root/ROOT/ __init__.py", line 22, in <module>
    import cppyy
  File "/usr/local/Cellar/root/6.22.08/lib/root/cppyy/ __init__.py", line 131, in <module>
    from ._cpython_cppyy import *
  File "/usr/local/Cellar/root/6.22.08/lib/root/cppyy/_cpython_cppyy.py", line 18, in <module>
    c = loader.load_cpp_backend()
  File "/usr/local/lib/python3.9/site-packages/cppyy_backend/loader.py", line 79, in load_cpp_backend
    c, err2 = _load_helper(name)
  File "/usr/local/Cellar/python@3.9/3.9.4/Frameworks/Python.framework/Versions/3.9/lib/python3.9/ctypes/ __init__.py", line 392, in __getitem__
    func = self._FuncPtr((name_or_ordinal, self))
TypeError: function name must be string, bytes object or integer

```

---

<div class="post-metadata">

**Author:** ![jalopezg](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/jalopezg/32/25844_2.png) [@jalopezg](https://root-forum.cern.ch/u/jalopezg)\
**Post date:** [May 3, 2021, 12:27pm UTC](https://root-forum.cern.ch/t/pyroot-broken-in-brew-again/44684/2 "2021-05-03T12:27:02Z")

</div>

Hi @jasondet,

It seems that you are still having problems while loading `libcppyy_backend.so`. I am not an expert in this area of ROOT, but it seems it might be related to the corresponding `ctypes.CDLL()` call. I am sure @etejedor can point you in the right direction.

Cheers,  
J.

---

<div class="post-metadata">

**Author:** ![etejedor](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/e/e79b87/32.png) [@etejedor](https://root-forum.cern.ch/u/etejedor)\
**Post date:** [May 3, 2021, 12:42pm UTC](https://root-forum.cern.ch/t/pyroot-broken-in-brew-again/44684/3 "2021-05-03T12:42:20Z")

</div>

Hello,

Your ROOT installation is using the` cppyy_backend` package that you installed separately, instead of its own (so ROOT’s cppyy and the cppyy you installed separately are mixing).

I’d try to go back to the situation where you got the “cppyy missing” warnings and we can try to solve it from there. In your previous post, I understood it was working. What changed?

---

<div class="post-metadata">

**Author:** ![jasondet](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/jasondet/32/25854_2.png) [@jasondet](https://root-forum.cern.ch/u/jasondet)\
**Post date:** [May 12, 2021, 8:27pm UTC](https://root-forum.cern.ch/t/pyroot-broken-in-brew-again/44684/4 "2021-05-12T20:27:38Z")

</div>

Okay – I have a fresh unadulturated install of brew’s root (`brew install root`). Here’s what I get:

```auto
jasondet@Jasons-MacBook-Pro ~ % root --version
ROOT Version: 6.22/08
Built for macosx64 on Mar 10 2021, 14:20:04
From tags/v6-22-08@v6-22-08

jasondet@Jasons-MacBook-Pro ~ % root-config --has-python
no

jasondet@Jasons-MacBook-Pro ~ % python
Python 3.9.5 (default, May 4 2021, 03:36:27) 
[Clang 12.0.0 (clang-1200.0.32.29)] 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.22.08_1/lib/root/ROOT/ __init__.py", line 22, in <module>
    import cppyy
  File "/usr/local/Cellar/root/6.22.08_1/lib/root/cppyy/ __init__.py", line 131, in <module>
    from ._cpython_cppyy import *
  File "/usr/local/Cellar/root/6.22.08_1/lib/root/cppyy/_cpython_cppyy.py", line 18, in <module>
    c = loader.load_cpp_backend()
  File "/usr/local/lib/python3.9/site-packages/cppyy_backend/loader.py", line 85, in load_cpp_backend
    raise RuntimeError("could not load cppyy_backend library, details:\n%s" %
RuntimeError: could not load cppyy_backend library, details:
  dlopen(/usr/local/lib/python3.9/site-packages/cppyy_backend/lib/libcppyy_backend3_9.so, 10): image not found
  dlopen(libcppyy_backend3_9.so, 10): image not found
>>> 

```

---

<div class="post-metadata">

**Author:** ![schellman](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/s/d26b3c/32.png) [@schellman](https://root-forum.cern.ch/u/schellman)\
**Post date:** [May 14, 2021, 2:35pm UTC](https://root-forum.cern.ch/t/pyroot-broken-in-brew-again/44684/5 "2021-05-14T14:35:36Z")

</div>

I am not an expert but I had issues after installing the latest Xcode. I most likely can’t help you but knowing which Xcode you have will help. 12.5 broke my setup on OSX.

---

<div class="post-metadata">

**Author:** ![system](https://root-forum.cern.ch/uploads/default/original/3X/e/f/efe4f24398fd8ffeb76bccb6ecc46d9d9c003376.png) [@system](https://root-forum.cern.ch/u/system)\
**Post date:** [May 28, 2021, 2:36pm UTC](https://root-forum.cern.ch/t/pyroot-broken-in-brew-again/44684/6 "2021-05-28T14:36:31Z")

</div>

Closed on May 28, 2021, 2:36pm UTC

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

---

<div class="post-metadata">

**Author:** ![etejedor](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/e/e79b87/32.png) [@etejedor](https://root-forum.cern.ch/u/etejedor)\
**Post date:** [June 7, 2021, 11:40am UTC](https://root-forum.cern.ch/t/pyroot-broken-in-brew-again/44684/8 "2021-06-07T11:40:13Z")

</div>

This looks like an interference between the `cppyy` you installed via pip in `/usr/local/lib/python3.9/site-packages` and the one that comes with ROOT (which you installed via brew). I would recommend to uninstall the former and try again.
