How to make an executable that includes pandas-profiling?

Viewed 184

Based on this ticket https://github.com/pandas-profiling/pandas-profiling/issues/706 (suggesting to ask on stackoverflow), is there any way (maybe a modified spec file) to get a simple executable from pyinstaller that uses pandas profiling? For reference, my current python code to achieve this looks like this

import pandas as pd
import os
from pandas_profiling import ProfileReport
from multiprocessing import Process, freeze_support


def f():
    files = {}
    for filename in os.listdir(os.getcwd()):
        if filename.endswith('.csv'):
            with open(os.path.join(os.getcwd(), filename), 'r') as f:
                file = pd.read_csv(filename, sep=';')
                files[filename.replace('.csv', '')] = file

    for filename, file in files.items():
        profile = ProfileReport(file, title="Profiling Report {}".format(filename))
        profile.to_file("{}_report.html".format(filename))


if __name__ == '__main__':
    freeze_support()
    Process(target=f).start()

The freeze_support was added after reading suggestions that the multiprocessing used in pandas-profiling might cause problems with pyinstaller. The error I get when running the executable is 'No such file or directory', more specifically a missing config-default.yaml file for pandas-profiling. I added pandas-profiling to the hidden imports of my spec file, which doesn't change anything.

Has anyone figured out how to do it, maybe how to modify the spec file for pyinstaller?

0 Answers
Related