3

I'm installing meld as described here:

sudo yum install intltool itstool gir1.2-gtksource-3.0 libxml2-utils

However, when I try to run meld this error appears:

File "/usr/bin/meld", line 47
  print _("Meld requires %s or higher.") % modver
        ^

And indeed /usr/bin/meld has this code:

def missing_reqs(mod, ver):
    modver = mod + " " + ".".join(map(str, ver))
    print _("Meld requires %s or higher.") % modver
    sys.exit(1)

I'm on CentOS 6.7, Python version 3.3.5.

Could you advise on what I'm doing wrong here?


EDIT:

Here's the command line, verbatim:

$ meld
  File "/usr/bin/meld", line 47
    print _("Meld requires %s or higher.") % modver
          ^
SyntaxError: invalid syntax

Here is a portion of meld script:

import sys
if "--pychecker" in sys.argv:
    sys.argv.remove("--pychecker")
    import os
    os.environ['PYCHECKER'] = "--no-argsused --no-classattr --stdlib"
        #'--blacklist=gettext,locale,pygtk,gtk,gtk.keysyms,popen2,random,difflib,filecmp,tempfile'
    import pychecker.checker
#
# i18n support
#
sys.path[0:0] = [ "/usr/share/meld"
]
import paths
import gettext
_ = gettext.gettext

gettext.bindtextdomain("meld", paths.locale_dir())
gettext.textdomain("meld")

# Check requirements: Python 2.4, pygtk 2.8
pyver = (2,4)
pygtkver = (2,8,0)

def missing_reqs(mod, ver):
    modver = mod + " " + ".".join(map(str, ver))
    print _("Meld requires %s or higher.") % modver
    sys.exit(1)

if sys.version_info[:2] < pyver:
    missing_reqs("Python", pyver)
Michael
  • 5,775
  • 2
  • 34
  • 53

1 Answers1

1

print is a statement in python2 just like your script has:

print _("Meld requires %s or higher.") % modver

But you are interpreting the script using python3 which does not have print statement rather has print() function.

You can try to replace all print with print() with a hope that nothing else breaks, which is not a good solution anyway.

Better just install python2:

sudo yum install python2

and use python2 as the interpreter.

heemayl
  • 39,294
  • 7
  • 70
  • 76
  • Well, I have a bunch of tools installed on my machine that rely on python 3. Wouldn't installation of python 2 affect them because `#!python` would suddenly change from invoking python 3 to python 2? – Michael May 10 '16 at 16:13
  • @Michael Not really, you can call python2 by its path e.g. `/usr/bin/python2`..it shouldn't remove the current symlink of python to python3..if you are paranoid, you can install in a virtualenv.. – heemayl May 10 '16 at 16:16
  • Thanks, that helped. – Michael May 10 '16 at 19:07