dexplo / dataframe_image

A python package for embedding pandas DataFrames as images into pdf and markdown documents
https://dexplo.org/dataframe_image
MIT License
282 stars 41 forks source link

Error when calling "export" on Windows #86

Closed tdefise closed 1 year ago

tdefise commented 1 year ago

Hello,

It seems that I have an issue (which was not present in the past) when I try to export a dataframe towards an image. Here are some information:

I changed to this:

dfi.export(df_overall_vuln,'overal_vuln_'+asset_tags[0][1].lower()+'.PNG', table_conversion="selenium")

Thinking it could solve the issue, but it didn't solved it.

When I navigate to I correctly see both file

image

Here below is the output from geckodriver.log

image

temp.html looks how I would like to have the image.

Here is the stack trace

Traceback (most recent call last): File "\file-01\UserProfiles$\thde\Documents\BCRepos\security.pytenable\pyReports.py", line 671, in getVulnerabilitiesByTag([("OS", "Windows")]) File "\file-01\UserProfiles$\thde\Documents\BCRepos\security.pytenable\pyReports.py", line 653, in getVulnerabilitiesByTag dfi.export(df_overall_vuln,'overalvuln'+asset_tags[0][1].lower()+'.PNG', table_conversion="selenium") File "C:\Users\thde\AppData\Local\Programs\Python\Python310\lib\site-packages\dataframe_image_pandas_accessor.py", line 41, in export return _export(obj, filename, fontsize, max_rows, max_cols, table_conversion, chrome_path, dpi) File "C:\Users\thde\AppData\Local\Programs\Python\Python310\lib\site-packages\dataframe_image_pandas_accessor.py", line 122, in _export img_str = converter(html) File "C:\Users\thde\AppData\Local\Programs\Python\Python310\lib\site-packages\dataframe_image_screenshot.py", line 200, in run img = self.take_screenshot() File "C:\Users\thde\AppData\Local\Programs\Python\Python310\lib\site-packages\dataframe_image\selenium_screenshot.py", line 56, in take_screenshot with selenium.webdriver.Firefox(options=options, service=service) as driver: File "C:\Users\thde\AppData\Local\Programs\Python\Python310\lib\site-packages\selenium\webdriver\firefox\webdriver.py", line 199, in init super().init(command_executor=executor, options=options, keep_alive=True) File "C:\Users\thde\AppData\Local\Programs\Python\Python310\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 286, in init self.start_session(capabilities, browser_profile) File "C:\Users\thde\AppData\Local\Programs\Python\Python310\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 378, in start_session response = self.execute(Command.NEW_SESSION, parameters) File "C:\Users\thde\AppData\Local\Programs\Python\Python310\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 440, in execute self.error_handler.check_response(response) File "C:\Users\thde\AppData\Local\Programs\Python\Python310\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 245, in check_response raise exception_class(message, screen, stacktrace) selenium.common.exceptions.SessionNotCreatedException: Message: Expected browser binary location, but unable to find binary in default location, no 'moz:firefoxOptions.binary' capability provided, and no binary flag set on the command line

Traceback (most recent call last): File "C:\Users\thde\AppData\Local\Programs\Python\Python310\lib\shutil.py", line 617, in _rmtree_unsafe os.unlink(fullname) PermissionError: [WinError 32] The process cannot access the file because it is being used by another process: 'C:\Users\thde\AppData\Local\Temp\tmpqrvg1467\geckodriver.log'

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "C:\Users\thde\AppData\Local\Programs\Python\Python310\lib\tempfile.py", line 843, in onerror _os.unlink(path) PermissionError: [WinError 32] The process cannot access the file because it is being used by another process: 'C:\Users\thde\AppData\Local\Temp\tmpqrvg1467\geckodriver.log'

During handling of the above exception, another exception occurred: Traceback (most recent call last): f() File "C:\Users\thde\AppData\Local\Programs\Python\Python310\lib\weakref.py", line 591, in call return info.func(*info.args, **(info.kwargs or {})) File "C:\Users\thde\AppData\Local\Programs\Python\Python310\lib\tempfile.py", line 859, in _cleanup cls._rmtree(name, ignore_errors=ignore_errors) File "C:\Users\thde\AppData\Local\Programs\Python\Python310\lib\tempfile.py", line 855, in _rmtree _shutil.rmtree(name, onerror=onerror) File "C:\Users\thde\AppData\Local\Programs\Python\Python310\lib\shutil.py", line 749, in rmtree return _rmtree_unsafe(path, onerror) File "C:\Users\thde\AppData\Local\Programs\Python\Python310\lib\shutil.py", line 619, in _rmtree_unsafe File "C:\Users\thde\AppData\Local\Programs\Python\Python310\lib\tempfile.py", line 846, in onerror cls._rmtree(path, ignore_errors=ignore_errors) File "C:\Users\thde\AppData\Local\Programs\Python\Python310\lib\tempfile.py", line 855, in _rmtree _shutil.rmtree(name, onerror=onerror) File "C:\Users\thde\AppData\Local\Programs\Python\Python310\lib\shutil.py", line 749, in rmtree return _rmtree_unsafe(path, onerror) File "C:\Users\thde\AppData\Local\Programs\Python\Python310\lib\shutil.py", line 600, in _rmtree_unsafe onerror(os.scandir, path, sys.exc_info()) with os.scandir(path) as scandir_it: NotADirectoryError: [WinError 267] The directory name is invalid: 'C:\Users\thde\AppData\Local\Temp\tmpqrvg1467\geckodriver.log'

PaleNeutron commented 1 year ago

This should be fixed by version 0.1.10.

Try it and see if is fixed.