Menu

#173 apbstool plugin in pymol r4146 has python3 compatibility issues with pmw 2.0.0

v1.7.1.0
closed-invalid
None
5
2021-12-30
2015-12-12
No

The APBS Tools plugin in pymol r4146 has problems running against python 3.4.3 or 3.5.0 using Pmw 2.0.0. In the case of python 3.4.3, the APBS Tools can successfully open a pre-existing pqr file but when "Set Grid" is clicked, the error...

SyntaxError Exception in Tk callback
  Function: <function Dialog._buttons.<locals>.<lambda> at 0x109907c80> (type: <class 'function'>)
  Args: ()
Traceback (innermost last):
  File "/sw/lib/python3.4/site-packages/Pmw/Pmw_2_0_0/lib/PmwBase.py", line 1776, in __call__
    return self.func(*args)
  File "/sw/lib/python3.4/site-packages/Pmw/Pmw_2_0_0/lib/PmwDialog.py", line 152, in <lambda>
    command=lambda self=self, name=name: self._doCommand(name))
  File "/sw/lib/python3.4/site-packages/Pmw/Pmw_2_0_0/lib/PmwDialog.py", line 132, in _doCommand
    return command(name)
  File "/sw/lib/python3.4/site-packages/pmg_tk/startup/apbs_tools.py", line 1163, in execute
    self.runPsize()
  File "/sw/lib/python3.4/site-packages/pmg_tk/startup/apbs_tools.py", line 1202, in runPsize
    psize = imp.load_module('psize',f,fname,description)
  File "/sw/lib/python3.4/imp.py", line 235, in load_module
    return load_source(name, filename, file)
  File "/sw/lib/python3.4/imp.py", line 171, in load_source
    module = methods.load()
  File "<frozen importlib._bootstrap>", line 1220, in load
    None
  File "<frozen importlib._bootstrap>", line 1200, in _load_unlocked
    None
  File "<frozen importlib._bootstrap>", line 1129, in _exec
    None
  File "<frozen importlib._bootstrap>", line 1467, in exec_module
    None
  File "<frozen importlib._bootstrap>", line 1572, in get_code
    None
  File "<frozen importlib._bootstrap>", line 1532, in source_to_code
    None
  File "<frozen importlib._bootstrap>", line 321, in _call_with_frames_removed
    None
SyntaxError: invalid syntax (psize.py, line 362)

appears. When pymol r4146 is built against python 3.5.0 instead, the failure occurs earllier when the APBS Tools plugin attempts to open its window...

TypeError Exception in Tk callback
  Function: <function __init__.<locals>.<lambda> at 0x10c416c80> (type: <class 'function'>)
  Args: ()
Traceback (innermost last):
  File "/sw/lib/python3.5/site-packages/Pmw/Pmw_2_0_0/lib/PmwBase.py", line 1776, in __call__
    return self.func(*args)
  File "/sw/lib/python3.5/site-packages/pmg_tk/startup/apbs_tools.py", line 321, in <lambda>
    command = lambda s=self: APBSTools2(s))
  File "/sw/lib/python3.5/site-packages/pmg_tk/startup/apbs_tools.py", line 616, in __init__
    self.notebook = Pmw.NoteBook(self.dialog.interior())
  File "/sw/lib/python3.5/site-packages/Pmw/Pmw_2_0_0/lib/PmwNoteBook.py", line 60, in __init__
    Pmw.Color.bordercolors(self, self['hull_background'])
  File "/sw/lib/python3.5/site-packages/Pmw/Pmw_2_0_0/lib/PmwColor.py", line 359, in bordercolors
    '#%04x%04x%04x' % (lightRGB[0], lightRGB[1], lightRGB[2]),
TypeError: %x format: an integer is required, not float

Discussion

  • Jack Howarth

    Jack Howarth - 2015-12-12

    The failure under python 3.5.0 looks like that described in...

    https://bugs.python.org/issue23466

    but it isn't fixed in python 3.5.1 so perhaps it is yet another corner case?

     
  • Jack Howarth

    Jack Howarth - 2015-12-12

    The failure under python 3.5.0 is suppressed by applying....

    diff -uNr Pmw-2.0.0.orig/Pmw/Pmw_2_0_0/lib/PmwColor.py Pmw-2.0.0/Pmw/Pmw_2_0_0/lib/PmwColor.py
    --- Pmw-2.0.0.orig/Pmw/Pmw_2_0_0/lib/PmwColor.py        2013-02-26 08:01:23.000000000 -0500
    +++ Pmw-2.0.0/Pmw/Pmw_2_0_0/lib/PmwColor.py     2015-12-12 17:37:26.000000000 -0500
    @@ -356,6 +356,6 @@
             darkRGB.append(darkValue)
    
         return (
    
    -        '#%04x%04x%04x' % (lightRGB[0], lightRGB[1], lightRGB[2]),
    -        '#%04x%04x%04x' % (darkRGB[0], darkRGB[1], darkRGB[2])
    +        '#%04x%04x%04x' % (int(lightRGB[0]), int(lightRGB[1]), int(lightRGB[2])),
    +        '#%04x%04x%04x' % (int(darkRGB[0]), int(darkRGB[1]), int(darkRGB[2]))
         )
    

    to Pmw-2.0.0.

     
  • Jack Howarth

    Jack Howarth - 2015-12-12

    The failure under python 3.4.3 is suppressed by running the psize.py from apbs through 2to3-3.4 and using that recommended change...

    --- apbs/tools/manip/psize.py.orig      2015-12-12 13:01:10.000000000 -0500
    +++ apbs/tools/manip/psize.py   2015-12-12 13:01:57.000000000 -0500
    @@ -359,7 +359,7 @@
            longOptList = ["help", "cfac=", "fadd=", "space=", "gmemfac=", "gmemceil=", "ofrac=", "redfac=" ]
            try:
                    opts, args = getopt.getopt(sys.argv[1:], shortOptList, longOptList)
    
    -       except getopt.GetoptError, details:
    +       except getopt.GetoptError as details:
                    stderr.write("Option error (%s)!\n" % details)
                    usage(2)
            if len(args) != 1: 
    @@ -390,7 +390,7 @@
    
            psize.runPsize(filename)
            stdout.write("# Constants used: \n");
    
    -       for key in psize.constants.keys():
    +       for key in list(psize.constants.keys()):
                    stdout.write("# \t%s: %s\n" % (key, psize.constants[key]))
            stdout.write("# Run:\n")
            stdout.write("#    `%s --help`\n" % sys.argv[0])
    
     
  • Thomas Holder

    Thomas Holder - 2016-04-18
    • summary: apbstool plugin in pymol r4146 has python compatibility issues with omw 2.0.0 --> apbstool plugin in pymol r4146 has python3 compatibility issues with pmw 2.0.0
     
  • Alexey Strokach

    Alexey Strokach - 2016-10-11

    I think this could be fixed by replacing all lines similar to

    '#%04x%04x%04x' % (lightRGB[0], lightRGB[1], lightRGB[2])
    

    with

    #{0:X}{1:X}{2:X}".format(lightRGB[0], lightRGB[1], lightRGB[2])
    

    This is the approach taken to fix a similar error in yumex-dnf (issue, diff).

     

    Last edit: Alexey Strokach 2016-10-11
  • Thomas Holder

    Thomas Holder - 2016-12-05
    • status: open --> closed-invalid
    • assigned_to: Thomas Holder
     
  • Thomas Holder

    Thomas Holder - 2016-12-05

    as I understand, all requested changes are not in PyMOL, but in third party dependencies.

     
  • Artik Bohm

    Artik Bohm - 2021-12-30

    Probably a hack more than a patch, but I fixed it by casting to int():

    '#%04x%04x%04x' % (int(lightRGB[0]), int(lightRGB[1]), int(lightRGB[2])),
    '#%04x%04x%04x' % (int(darkRGB[0]), int(darkRGB[1]), int(darkRGB[2]))
    
     

Log in to post a comment.

MongoDB Logo MongoDB