Author Topic: Error rendering image python script  (Read 149 times)

jorgee

  • Newbie
  • *
  • Posts: 2
Error rendering image python script
« on: August 06, 2018, 11:13:39 PM »
Hi, I am getting this error when trying to render an image with python binding. Find below the stacktrace and the code snippet. I am using 2.9,0 version compiled from gitlab. Any hist about where can be the error?

File "/home/bsc19/bsc19611/decaf-test/decaf-pycompss/install/examples/lammps/freezing/decaf_compute_diamond_struct_experiment_pycompss.py", line 80, in render
    vp.render(rs)
  File "/home/bsc19/bsc19611/decaf-test/deps/ovito-v2.9.0/install/lib/ovito/plugins/python/ovito/vis/__init__.py", line 124, in _Viewport_render
    return fb.image
  File "/home/bsc19/bsc19611/decaf-test/deps/ovito-v2.9.0/install/lib/ovito/plugins/python/ovito/vis/__init__.py", line 90, in _get_FrameBuffer_image
    return PyQt5.QtGui.QImage(sip.wrapinstance(self._image, PyQt5.QtGui.QImage))
TypeError: wrapinstance() argument 2 must be sip.wrappertype, not sip.wrappertype

This is the code snippet I use

  node = import_file(iflstr, multiple_frames = False)
        print("Frame loaded. Total particles loaded: %i" %node.source.number_of_particles)

        #---Identify diamond structure---#
        modifier = IdentifyDiamondModifier(only_selected = False)
        node.modifiers.append(modifier)

        #---Add to scene---#
        node.add_to_scene()
        particle_display = node.source.particle_properties.position.display
        particle_display.radius = 2.0

        #---Render structure---#

        vp = Viewport()
        vp.type = Viewport.Type.PERSPECTIVE
        #vp.camera_pos = (1179, -403, 744)
        vp.camera_dir = (-0.76, -0.45, -0.47)
        tripod = CoordinateTripodOverlay()
        tripod.size = 0.07
        tripod.alignment = QtCore.Qt.AlignLeft ^ QtCore.Qt.AlignBottom
        vp.overlays.append(tripod)
        vp.zoom_all()

        rs = RenderSettings(
            filename = oflstr,
            size = (1600,1200),
            background_color = (1.0,1.0,1.0),
            renderer = TachyonRenderer()
        )

        rs.renderer.ambient_occlusion = True
        rs.renderer.ambient_occlusion_brightness=0.8
        rs.renderer.ambient_occlusion_samples=12
        rs.renderer.antialiasing = True
        rs.renderer.antialiasing_samples = 12
        rs.renderer.direct_light = True
        rs.renderer.shadows = True
        vp.render(rs)



« Last Edit: August 07, 2018, 11:11:17 AM by Alexander Stukowski »

Alexander Stukowski

  • Administrator
  • Sr. Member
  • *****
  • Posts: 475
Re: Error redering image python script
« Reply #1 on: August 07, 2018, 08:23:42 AM »
Hi,

I haven't seen this error message before and seems confusing as you probably agree:
Code: [Select]
TypeError: wrapinstance() argument 2 must be sip.wrappertype, not sip.wrappertype

My guess is that this error is due to some sort of installation compatibility problem. Maybe you are mixing different versions of the same library in the same program, perhaps the PyQt5 module libraries. In particular, make sure that the PyQt5 module installed in your Python interpreter was built against the same Qt libraries which Ovito was built against.

One question: Are you running this script through the 'ovitos' interpreter or a standard CPython interpreter?

jorgee

  • Newbie
  • *
  • Posts: 2
Re: Error redering image python script
« Reply #2 on: August 07, 2018, 10:12:56 AM »
Yes, It could be the issue.
I am installing it in a supercomputer where libraries versions management are a little bit complicated. Do you know which variables I have to set in the cmake specify the Qt5 libraries in the ovitos compilation? I am using the CPython interpreter.


Alexander Stukowski

  • Administrator
  • Sr. Member
  • *****
  • Posts: 475
Re: Error redering image python script
« Reply #3 on: August 07, 2018, 10:32:38 AM »
You can check which installation of the Qt libraries Ovito is being built against by running "cmake -L" in the build directory. You should look for a set of cmake variables named "Qt5*_DIR" which point to the Qt library directory. 

To find out which version of Qt the PyQt5 Python module is loading, start up your Python interpreter and execute

Code: [Select]
import PyQt5
print(PyQt5.__path__)

The directory path should contain a bunch of shared library files (Qt*.so). Run "ldd" on one of these .so files in the terminal to find out which Qt installation it was linked to. If it just says "statically linked", you may have a problem. It would mean that Qt was statically linked into the PyQt5 module libraries and there is no way for Ovito to use the same Qt libraries. I think in this case it might become necessary to rebuild the PyQt5 Python module from source.