Unable to compile ROOT because of python version error

Hi all,
I am trying to compile root on System76 Gazelle Professional laptop running Arch linux. I did git clone root.cern.ch/git/root.git, cd’d into the root directory, and did ./configure.

When execute make, I get the following error,

checking for python... /usr/bin/python checking for python >= 2.5... File "<string>", line 1 import sys; print sys.version.split()[0] ^ SyntaxError: invalid syntax /home/raphael/root/interpreter/llvm/src/configure: line 11822: test: : integer expression expected not found configure: error: found python (/usr/bin/python); required >= 2.5 See `config.log' for more details. /home/raphael/root/interpreter/llvm/Module.mk:99: recipe for target 'interpreter/llvm/obj/Makefile.config' failed make: *** [interpreter/llvm/obj/Makefile.config] Error 1

I have both python 3.3.3-1 and python2 2.7.6-1. I don’t understand how to fix this error. Can someone help me fix it?

In Arch linux, python2.7.6 is named python2 instead of python if that helps in solving the problem.

Thank you in advance!
-Raphael

Hi,

that’s a problem in llvm, not in ROOT sec. At issue is that ‘print’ is a function in p3, no longer a keyword. You can look at ROOT’s configure how to fix llvm’s configure:pythonvers=`python -c 'import sys; sys.stdout.write(sys.version[:3])'`
which specifically I’d figure would translate into this for your case:import sys; sys.stdout.write(sys.version.split()[0]); sys.stdout.write('\n')(note sure whether you need the last \n).

HTH,
Wim

I tried changing

to
pythonvers=`python -c 'import sys; sys.stdout.write(sys.version.split()[0]); sys.stdout.write('\n')'`
in my configure file, but I still get the same error message. I also tried taking out the write(’\n’) part. Did I misunderstand what you said?

Hi,

yes, you misunderstood. Like I said, the problem is NOT in ROOT’s configure. Instead, that’s where you find how things should be. The problem is in llvm’s configure. So, do not modify ROOT’s configure, but llvm’s.

That latter file is here:$ROOTSYS/interpreter/llvm/src/configure and the problem is in line 11818. See your own original error message that you posted at the start of this thread.

That line 11818 needs to be changed into something resembling what you find in ROOT’s configure, which is where I was quoting from (the version checks are not exactly the same, but close).

To be explicit (haven’t tried), this:ac_python_version=`$PYTHON -c 'import sys; print sys.version.split()[0]'`
should become something like:ac_python_version=`$PYTHON -c 'import sys; sys.stdout.write(sys.version.split()[0])'`(w/o line split, not sure how it prints on your screen). The point being that both p2 and p3 can handle sys.stdout.write(), whereas only p2 can handle print statements. (And again, I don’t know whether you need the extra eol, but looks like it you don’t.)

Cheers,
Wim

P.S. I don’t actually know why llvm is using python and whether or not it may fail further down. You could also consider modifying in same configure file $PYTHON to read /usr/bin/python2.

Cheers,
Wim

I don’t have the $ROOTSYS file defined. I assume it’s the directory where I am trying to compile root. In that case, it’s /home/raphael/root/interpreter/llvm/src/configure. Let me know if that’s wrong.

I made the change you specified in llvm configure file. I did ./configure again, and then I tried to compile it. I still get the same error message.

checking for python... /usr/bin/python checking for python >= 2.5... not found configure: error: found python 3.3.3 (/usr/bin/python); required >= 2.5 See `config.log' for more details. /home/raphael/root/interpreter/llvm/Module.mk:99: recipe for target 'interpreter/llvm/obj/Makefile.config' failed make: *** [interpreter/llvm/obj/Makefile.config] Error 1

I also thought about defining PYTHON to be /usr/bin/python2, but I don’t exactly know how or where to define that in the llvm configure file. Sorry for being so ignorant.

I really appreciate your help. Your a lifesaver!

Hi,

not the same: the printing now worked, just that llvm does not like p3, since it -eq’s the first digit to 2:if test "$ac_python_version_major" -eq "2" \ && test "$ac_python_version_minor" -ge "5" ; then { echo "$as_me:$LINENO: result: $PYTHON ($ac_python_version)" >&5 echo "${ECHO_T}$PYTHON ($ac_python_version)" >&6; }
figures …

This seems to be the easiest (since you’re re-running configure locally anyway:PYTHON=/usr/bin/python2 ./configure
The other option seems to be to modify line 11770:set dummy python python2 python26; ac_word=$2which are the python executable names that are tried in-order. Either move ‘python2’ one place up, or drop ‘python’ altogether:set dummy python2 python26; ac_word=$2
HTH,
Wim


Didn't work. However,

Changing the llvm configure file to 
[code]    set dummy python2 python26; ac_word=$2[/code]
did work out.

I seemed to have gotten past that error. But now I run into other errors.

Thank you so much!

Didn’t work. However,

Changing the llvm configure file to

did work out.

I seemed to have gotten past that error. But now I run into other errors.

Thank you so much!