[Python] dataframe_image error: subprocess.CalledProcessError: Command (args) returned...

Discussão em 'Python' iniciado por Stack, Setembro 14, 2024.

  1. Stack

    Stack Membro Participativo

    I have been using dataframe_image for a couple years and am stuck on an error that just occurred today. I am getting the following error when trying to run dfi.export (index axis hidden,fontsize and dpi specified) for a dataframe.

    Traceback (most recent call last):
    File "C:\Users\david.clark\REPORT_TrendQuality\venv\lib\site-packages\dataframe_image\_screenshot.py", line 142, in take_screenshot
    self.generate_image_from_html(args)
    File "C:\Users\david.clark\REPORT_TrendQuality\venv\lib\site-packages\dataframe_image\_screenshot.py", line 150, in generate_image_from_html
    subprocess.run(executable=self.chrome_path, args=args, capture_output=True, check=True)
    File "C:\Users\david.clark\AppData\Local\Programs\Python\Python38\lib\subprocess.py", line 516, in run
    raise CalledProcessError(retcode, process.args,
    subprocess.CalledProcessError: Command '['--enable-logging', '--disable-gpu', '--headless', '--crash-dumps-dir=C:\\Users\\DAVID~1.CLA\\AppData\\Local\\Temp\\tmpw370ybdw', '--force-device-scale-factor=2.0', '--window-size=1400,900', '--hide-scrollbars', '--screenshot=C:\\Users\\DAVID~1.CLA\\AppData\\Local\\Temp\\tmpw370ybdw\\temp.png', 'C:\\Users\\DAVID~1.CLA\\AppData\\Local\\Temp\\tmpw370ybdw\\temp.html']' returned non-zero exit status 21.


    This seems to be occurring in _screenshot.py. I suspect it has something to do with the args for generate_image_from_html but have no clue what's wrong. I also wonder if it's due to any recent Chrome updates since I've had issues with that in the past. Anyone know what's going on here?

    I ran the following code:

    metrics_df = metrics_df.style.hide(axis="index")
    dfi.export(metrics_df, '{}_{}_{}_trend_quality_table_1.png'.format(row['CDAP Env.'], row['Patient ID'], row['Cordella ID']),
    fontsize=10, dpi=200)


    I was expecting a file named 'a_b_c_trend_quality_table_1.png' to appear in my working directory which would be an image of the metrics dataframe.


    Solution (Credit: Andrews): I added the table_conversion argument to dfi.export. I believe the default was chrome and by changing this (I used matplotlib) the code worked.

    Continue reading...

Compartilhe esta Página