Error when running a python script


When I try to run a script the following error occurs:
“ImportError: /work/astropa/sw/veritas/root-cern/build/lib/ undefined symbol: PyUnicodeUCS2_FromString”

Ubuntu 16.04
Python version 3.6.3
Root version 6.10
This is my .bash_profile:

source /work/astropa/sw/veritas/root-cern/build/bin/




*I don’t have permission from ROOT. Therefore, I can’t install or change stuff in it.

Would appreciate any help,

welcome to the ROOT forum!

This looks like a python version mismatch between your ROOT installation and the python you are using to run scripts. Can you try running the script with python2 instead of python or python3?


I am getting the same error with Python2 and the others as well.
This would be the complete output when I run the script (if it helps):
“File “”, line 2, in
import ROOT
File “/work/astropa/sw/veritas/root-cern/build/lib/”, line 24, in
import cppyy
File “/work/astropa/sw/veritas/root-cern/build/lib/”, line 61, in
import libPyROOT as _backend
ImportError: /work/astropa/sw/veritas/root-cern/build/lib/ undefined symbol: PyUnicodeUCS2_FromString”

Uhm are you sure your ROOT installation is meant for your python environment? Are you using the system’s python or did you get python e.g via conda?

Calling in the python experts: @etejedor and @swunsch in case they have seen this before

Yes, I doubled checked that it was the right environment. And I am using the system’s Python.

The error you see seems to be related to this issue:

Long story short, your Python installation is compiled with 4-byte unicode characters (UCS4) but ROOT was built against a Python installation with 2-byte unicode characters (UCS2). That is why your Python installation does not provide PyUnicodeUCS2_FromString.

I see two possible solutions:

  • You build ROOT against the UCS4 Python you have in your system (or ask someone that has permissions to do it).
  • You install a Python that has UCS2, so that ROOT will find the symbol. It seems the flag is --enable-unicode=ucs2.
1 Like

Thank you! I appreciate it.