Menu

#221 pyFoamPVSnapshot.py with pvpython3 not working

new
nobody
None
normal
minor
HaveNotTried
none
general
2017-09-23
2017-09-22
No

Discussion

  • Bernhard Gschaider

    Seems your version of Paraview is compiled with Python3 instead of Python2. Which is not bad but a bit unusual: the binaries that KitWare delivers are still using python2 so the problem didn't bite anyone yet.

    At the time that these utilies were made Paraview didn't even pretend to support Python3 so I never bothered to make the sources compatible with Python2 and Python3

    The first problem (changed syntax for print) you did already solve. Athough a better solution would be to use

    from PyFoam.ThirdParty.six import print_
    

    and then use print_ instead of print. That way it would be compatible with python2 and 3

    The second problem is a change in the way Python3 imports modules that are in the same directory. Replace

    from PyFoamApplication import PyFoamApplication
    

    with

    from .PyFoamApplication import PyFoamApplication
    

    and everything should be fine. Except for possible other errors that haven't surfaced yet.

    Should these changes be sufficient could you please attach the modified file here and I'll work them into the code-base. Otherwise I'll have a look next week in the office where I happen to have a virtual machine with Manjaro. What I'd need to know: where did you get the paraview with python3?

     
  • Robin Rosenstock

    Hello Bernhard Gschaider,
    yes, I've compiled Paraview myself from this Aur: https://aur.archlinux.org/packages/paraview/
    After making the changing your suggested, I get this output when executing PyFoamPVSnapshot.py

    Executing PVSnapshot with pvpython trough a proxy-script options: 
    Traceback (most recent call last):
      File "/tmp/pyFoamPVSnapshot_i61_e_7z.py", line 4, in <module>
        PVSnapshot()
      File "/home/robin/miniconda3/lib/python3.6/site-packages/PyFoam/Applications/PVSnapshot.py", line 54, in __init__
        **kwargs)
      File "/home/robin/miniconda3/lib/python3.6/site-packages/PyFoam/Applications/PyFoamApplication.py", line 326, in __init__
        self.addOptions()
      File "/home/robin/miniconda3/lib/python3.6/site-packages/PyFoam/Applications/PVSnapshot.py", line 85, in addOptions
        help="The type of the bitmap-file. Possibilities are "+", ".join(self.picTypeTable.keys())+". Default: %default")
      File "/usr/lib/python3.6/optparse.py", line 1000, in add_option
        option = self.option_class(*args, **kwargs)
      File "/usr/lib/python3.6/optparse.py", line 581, in __init__
        checker(self)
      File "/usr/lib/python3.6/optparse.py", line 670, in _check_choice
        % str(type(self.choices)).split("'")[1], self)
    optparse.OptionError: option --type: choices must be a list of strings ('dict_keys' supplied)
    
     
  • Bernhard Gschaider

    Replacing

    choices=self.picTypeTable.keys()
    

    with

    choices=list(self.picTypeTable.keys())
    

    might do the trick

     
  • Robin Rosenstock

    Unfortunatly this does not work:

    Traceback (most recent call last):
      File "/tmp/pyFoamPVSnapshot_a5fzq24y.py", line 4, in <module>
        PVSnapshot()
      File "/home/robin/miniconda3/lib/python3.6/site-packages/PyFoam/Applications/PVSnapshot.py", line 54, in __init__
        **kwargs)
      File "/home/robin/miniconda3/lib/python3.6/site-packages/PyFoam/Applications/PyFoamApplication.py", line 326, in __init__
        self.addOptions()
      File "/home/robin/miniconda3/lib/python3.6/site-packages/PyFoam/Applications/PVSnapshot.py", line 113, in addOptions
        help="The type of the geometry-files. Possibilities are "+", ".join(self.geomTypeTable.keys())+". Default: unset. Nothing is written")
      File "/usr/lib/python3.6/optparse.py", line 1000, in add_option
        option = self.option_class(*args, **kwargs)
      File "/usr/lib/python3.6/optparse.py", line 581, in __init__
        checker(self)
      File "/usr/lib/python3.6/optparse.py", line 670, in _check_choice
        % str(type(self.choices)).split("'")[1], self)
    
     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.