'dataframe-image 0.1.1 does not export as image

The library dataframe_image is being used to convert a dataframe to png at spyder. However, it sends an error when the example code is executed.

The error is:

Traceback (most recent call last):

  File "C:\Users\hnunezc\Reporte 2021\untitled9.py", line 36, in <module>
    dfi.export(df_styled,'df_styled.png')

  File "C:\Users\hnunezc\AppData\Roaming\Python\Python38\site-packages\dataframe_image\_pandas_accessor.py", line 24, in export
    return _export(obj, filename, fontsize, max_rows, max_cols, table_conversion, chrome_path)

  File "C:\Users\hnunezc\AppData\Roaming\Python\Python38\site-packages\dataframe_image\_pandas_accessor.py", line 32, in _export
    converter = Screenshot(max_rows=max_rows, max_cols=max_cols, chrome_path=chrome_path,

  File "C:\Users\hnunezc\AppData\Roaming\Python\Python38\site-packages\dataframe_image\_screenshot.py", line 76, in __init__
    self.chrome_path = get_chrome_path(chrome_path)

  File "C:\Users\hnunezc\AppData\Roaming\Python\Python38\site-packages\dataframe_image\_screenshot.py", line 60, in get_chrome_path
    handle = winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE, loc)


FileNotFoundError: [WinError 2] El sistema no puede encontrar el archivo especificado
                                (The system cannot find the file specified)

Does someone know if this library only works for jupyter notebooks or if there could be another reason behind the error?

Here is the code attempted to be run:

import dataframe_image as dfi

df = pd.DataFrame(np.random.rand(4,6))

df_styled= df.style.background_gradient()
df_styled

dfi.export(df_styled,'df_styled.png')


Solution 1:[1]

I had a similar issue. My application worked fine on my machine (classic :p) and failed when my colleague cloned the repo. After much head scratching and when I looked in the documentation there was a very clear statement that Google Chrome needs to be installed for this to work properly. My colleague didn't have Chrome installed. After installing, it worked. Not saying this may be the exact fault here, but I landed here during my search and thought it might help somebody.

Screenshot from the docs below:

enter image description here

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Fraser Mclean