Hey,
When I try to run a script the following error occurs:
“ImportError: /work/astropa/sw/veritas/root-cern/build/lib/libPyROOT.so: 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/thisroot.sh
export PATH=$ROOTSYS/bin:$PYTHONDIR/bin:$PATH
export LD_LIBRARY_PATH=$ROOTSYS/lib:$PYTHONDIR/lib:$LD_LIBRARY_PATH
export PYTHONPATH=$ROOTSYS/lib:$PYTHONPATH
*I don’t have permission from ROOT. Therefore, I can’t install or change stuff in it.
Would appreciate any help,
Kayshla
Hi,
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
?
Cheers,
Enrico
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 “Anderson.py”, line 2, in
import ROOT
File “/work/astropa/sw/veritas/root-cern/build/lib/ROOT.py”, line 24, in
import cppyy
File “/work/astropa/sw/veritas/root-cern/build/lib/cppyy.py”, line 61, in
import libPyROOT as _backend
ImportError: /work/astropa/sw/veritas/root-cern/build/lib/libPyROOT.so: 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:
https://bugs.python.org/issue8654
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.