# Cannot import ROOT on Python

**URL:** <https://root-forum.cern.ch/t/cannot-import-root-on-python/40142>\
**Category:** ROOT\
**Created:** [June 30, 2020, 4:17am UTC](https://root-forum.cern.ch/t/cannot-import-root-on-python/40142 "2020-06-30T04:17:30Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Misaki\_Mizmoto](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/misaki_mizmoto/32/22563_2.png) [@Misaki\_Mizmoto](https://root-forum.cern.ch/u/Misaki_Mizmoto)\
**Post date:** [June 30, 2020, 4:17am UTC](https://root-forum.cern.ch/t/cannot-import-root-on-python/40142/1 "2020-06-30T04:17:32Z")

</div>

Hi,

I cannot import ROOT on Python. Would you please teach me how to fix it?

I am using  
macOS Catalina (v10.15.5)  
python v3.7.7  
ROOT v6.20/04  
and my path is

```auto
rootver=6.20.04_1
export ROOTSYS=/usr/local/Cellar/root/${rootver}
export PYTHONPATH=$ROOTSYS/lib/root
source $ROOTSYS/bin/thisroot.sh

```

The log is as follows:

```auto
$ python3
Python 3.7.7 (default, Mar 10 2020, 15:43:27) 
[Clang 10.0.0 (clang-1000.11.45.5)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import ROOT

 ***Break*** segmentation violation
[/usr/lib/system/libsystem_platform.dylib] _sigtramp (no debug info)
[<unknown binary>] (no debug info)
[/usr/local/opt/python@3.8/Frameworks/Python.framework/Versions/3.8/Python] PyUnicode_InternFromString (no debug info)
[/usr/local/Cellar/root/6.20.04_1/lib/root/libPyROOT.so] PyROOT::CreatePyStrings() (no debug info)
[/usr/local/Cellar/root/6.20.04_1/lib/root/libPyROOT.so] PyInit_libPyROOT (no debug info)
[/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/Python] _PyImport_LoadDynamicModuleWithSpec (no debug info)
[/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/Python] _imp_create_dynamic (no debug info)
[/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/Python] _PyMethodDef_RawFastCallDict (no debug info)
[/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/Python] _PyCFunction_FastCallDict (no debug info)
[/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/Python] _PyEval_EvalFrameDefault (no debug info)
[/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/Python] _PyEval_EvalCodeWithName (no debug info)
[/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/Python] _PyFunction_FastCallKeywords (no debug info)
[/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/Python] call_function (no debug info)
[/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/Python] _PyEval_EvalFrameDefault (no debug info)
[/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/Python] function_code_fastcall (no debug info)
[/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/Python] call_function (no debug info)
[/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/Python] _PyEval_EvalFrameDefault (no debug info)
[/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/Python] function_code_fastcall (no debug info)
[/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/Python] call_function (no debug info)
[/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/Python] _PyEval_EvalFrameDefault (no debug info)
[/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/Python] function_code_fastcall (no debug info)
[/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/Python] call_function (no debug info)
[/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/Python] _PyEval_EvalFrameDefault (no debug info)
[/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/Python] function_code_fastcall (no debug info)
[/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/Python] call_function (no debug info)
[/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/Python] _PyEval_EvalFrameDefault (no debug info)
[/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/Python] function_code_fastcall (no debug info)
[/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/Python] object_vacall (no debug info)
[/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/Python] _PyObject_CallMethodIdObjArgs (no debug info)
[/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/Python] PyImport_ImportModuleLevelObject (no debug info)
[/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/Python] _PyEval_EvalFrameDefault (no debug info)
[/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/Python] _PyEval_EvalCodeWithName (no debug info)
[/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/Python] PyEval_EvalCode (no debug info)
[/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/Python] builtin_exec (no debug info)
[/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/Python] _PyMethodDef_RawFastCallDict (no debug info)
[/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/Python] _PyCFunction_FastCallDict (no debug info)
[/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/Python] _PyEval_EvalFrameDefault (no debug info)
[/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/Python] _PyEval_EvalCodeWithName (no debug info)
[/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/Python] _PyFunction_FastCallKeywords (no debug info)
[/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/Python] call_function (no debug info)
[/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/Python] _PyEval_EvalFrameDefault (no debug info)
[/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/Python] function_code_fastcall (no debug info)
[/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/Python] call_function (no debug info)
[/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/Python] _PyEval_EvalFrameDefault (no debug info)
[/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/Python] function_code_fastcall (no debug info)
[/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/Python] call_function (no debug info)
[/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/Python] _PyEval_EvalFrameDefault (no debug info)
[/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/Python] function_code_fastcall (no debug info)
[/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/Python] call_function (no debug info)
[/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/Python] _PyEval_EvalFrameDefault (no debug info)
[/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/Python] function_code_fastcall (no debug info)
[/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/Python] object_vacall (no debug info)
[/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/Python] _PyObject_CallMethodIdObjArgs (no debug info)
[/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/Python] PyImport_ImportModuleLevelObject (no debug info)
[/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/Python] _PyEval_EvalFrameDefault (no debug info)
[/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/Python] _PyEval_EvalCodeWithName (no debug info)
[/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/Python] PyEval_EvalCode (no debug info)
[/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/Python] builtin_exec (no debug info)
[/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/Python] _PyMethodDef_RawFastCallDict (no debug info)
[/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/Python] _PyCFunction_FastCallDict (no debug info)
[/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/Python] _PyEval_EvalFrameDefault (no debug info)
[/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/Python] _PyEval_EvalCodeWithName (no debug info)
[/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/Python] _PyFunction_FastCallKeywords (no debug info)
[/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/Python] call_function (no debug info)
[/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/Python] _PyEval_EvalFrameDefault (no debug info)
[/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/Python] function_code_fastcall (no debug info)
[/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/Python] call_function (no debug info)
[/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/Python] _PyEval_EvalFrameDefault (no debug info)
[/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/Python] function_code_fastcall (no debug info)
[/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/Python] call_function (no debug info)
[/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/Python] _PyEval_EvalFrameDefault (no debug info)
[/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/Python] function_code_fastcall (no debug info)
[/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/Python] call_function (no debug info)
[/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/Python] _PyEval_EvalFrameDefault (no debug info)
[/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/Python] function_code_fastcall (no debug info)
[/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/Python] object_vacall (no debug info)
[/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/Python] _PyObject_CallMethodIdObjArgs (no debug info)
[/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/Python] PyImport_ImportModuleLevelObject (no debug info)
[/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/Python] _PyEval_EvalFrameDefault (no debug info)
[/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/Python] _PyEval_EvalCodeWithName (no debug info)
[/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/Python] PyEval_EvalCode (no debug info)
[/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/Python] run_mod (no debug info)
[/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/Python] PyRun_InteractiveOneObjectEx (no debug info)
[/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/Python] PyRun_InteractiveLoopFlags (no debug info)
[/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/Python] PyRun_AnyFileExFlags (no debug info)
[/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/Python] pymain_main (no debug info)
[/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/Python] _Py_UnixMain (no debug info)
[/usr/lib/system/libdyld.dylib] start (no debug info)
[<unknown binary>] (no debug info)

```

---

<div class="post-metadata">

**Author:** ![eguiraud](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/eguiraud/32/32217_2.png) [@eguiraud](https://root-forum.cern.ch/u/eguiraud)\
**Post date:** [June 30, 2020, 7:33am UTC](https://root-forum.cern.ch/t/cannot-import-root-on-python/40142/2 "2020-06-30T07:33:16Z")

</div>

Hi @Misaki_Mizmoto ,  
and welcome to the ROOT forum!

There seems to be a python version mismatch somewhere: your Cellar mentions python 3.7 but the stacktrace also mentions `/usr/local/opt/python@3.8/Frameworks/Python.framework/Versions/3.8/Python`.

Could it be that you have to re-install ROOT via homebrew after an operating system update?

Also pinging @henryiii in case he has seen this problem before.  
Cheers,  
Enrico

---

<div class="post-metadata">

**Author:** ![amadio](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/amadio/32/12562_2.png) [@amadio](https://root-forum.cern.ch/u/amadio)\
**Post date:** [June 30, 2020, 7:44am UTC](https://root-forum.cern.ch/t/cannot-import-root-on-python/40142/3 "2020-06-30T07:44:25Z")

</div>

> [@ROOT Installs with Python 3.8.2](https://root-forum.cern.ch/t/root-installs-with-python-3-8-2/40044/3):
>
> Try export PYTHONPATH=$(root-config --libdir), and please make sure to use the Python interpreter from Homebrew (i.e. likely from /usr/local/bin and linked somewhere into /usr/local/Cellar).

---

<div class="post-metadata">

**Author:** ![Misaki\_Mizmoto](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/misaki_mizmoto/32/22563_2.png) [@Misaki\_Mizmoto](https://root-forum.cern.ch/u/Misaki_Mizmoto)\
**Post date:** [June 30, 2020, 8:22am UTC](https://root-forum.cern.ch/t/cannot-import-root-on-python/40142/4 "2020-06-30T08:22:10Z")

</div>

Thank you for your comments. I read the @henryiii 's post ([ROOT Installs with Python 3.8.2](https://root-forum.cern.ch/t/root-installs-with-python-3-8-2/40044/3)), install python3.8, and can use pyROOT on python3.8.

---

<div class="post-metadata">

**Author:** ![henryiii](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/henryiii/32/14065_2.png) [@henryiii](https://root-forum.cern.ch/u/henryiii)\
**Post date:** [July 8, 2020, 8:25pm UTC](https://root-forum.cern.ch/t/cannot-import-root-on-python/40142/5 "2020-07-08T20:25:11Z")

</div>

Homebrew finished the 3.8 migration yesterday. `python3` is now Python 3.8, and extra workarounds shouldn’t be required now.

---

<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:** [July 22, 2020, 8:25pm UTC](https://root-forum.cern.ch/t/cannot-import-root-on-python/40142/6 "2020-07-22T20:25:13Z")

</div>

Closed on July 22, 2020, 8:25pm UTC

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