Pandas dataframe .to_json() crashes Custom Application

Hi,

I have a custom app built with SlicerCustomAppTemplate (slicer 5.2.2).

I compiled the application on ubuntu 20.04 (docker), and a weird thing is happening.

calling .to_json() from any pandas dataframe crashes the application with “exit abnormally”

a simple example like this will crash:

import pandas as pd
import numpy as np

random_table = pd.DataFrame(np.random.rand(5, 4), columns=[‘A’, ‘B’, ‘C’, ‘D’])
random_table.to_json()
(of course after slicer.util.pip_install(‘pandas’) resolves successfully)

Note that this does not crash when being executed just with PythonSlicer, but only when the app is running (headless or not). This also does not happen on stable linux Slicer downloaded from the website.

Downgrading pandas to older versions does not solve the issue.

Not sure how to debug this. Will try a debug build, but I am not sure it will catch the error when slicer exits abnormally.

My workaround will be to push this piece of code to a python subprocess.
But if anyone has a feeling on what it might be that would be great.

Cheers

My guess would be that you’ve got two versions of python packages mixed in your pythonpath or similar. Maybe run your process with strace to see what it’s doing just before it crashes.

1 Like