Bug description
Error occurring in celery worker while exporting dashboard as PDF using chrome driver
`The above exception was the direct cause of the following exception:
Traceback (most recent call last): File "C:\venv\Lib\site-packages\superset\tasks\scheduler.py", line 95, in execute ).run() ^^^^^ File "C:\venv\Lib\site-packages\superset\utils\decorators.py", line 266, in wrapped return on_error(ex) ^^^^^^^^^^^^ File "C:\venv\Lib\site-packages\superset\utils\decorators.py", line 236, in on_error raise ex File "C:\venv\Lib\site-packages\superset\utils\decorators.py", line 259, in wrapped result = func(args, *kwargs) ^^^^^^^^^^^^^^^^^^^^^ File "C:\venv\Lib\site-packages\superset\commands\report\execute.py", line 803, in run raise ReportScheduleUnexpectedError(str(ex)) from ex superset.commands.report.exceptions.ReportScheduleUnexpectedError: name 'Image' is not defined`
Screenshots/recordings
No response
Superset version
4.1.0
Python version
3.11
Node version
18 or greater
Browser
Chrome
Additional context
No response
Checklist
- [x] I have searched Superset docs and Slack and didn't find a solution to my problem.
- [x] I have searched the GitHub issue tracker and didn't find a similar bug report.
- [x] I have checked Superset's logs for errors and if I found a relevant Python stacktrace, I included it here as text in the "additional context" section.
Comment From: dosubot[bot]
To resolve the "name 'Image' is not defined" error in the Celery worker while exporting a dashboard as PDF using the Chrome driver in Superset version 4.1.0 with Python 3.11, you need to ensure that the Python Imaging Library (PIL) is installed. This error occurs because the Image
module from PIL is not found. You can fix this by installing the Pillow
package, which is the modern version of PIL. Run the following command to install it:
pip install Pillow
This will make the Image
module available, resolving the error [1].
To continue talking to Dosu, mention @dosu.
Comment From: rusackas
Could be that you're running it on Windows, which is not supported... could be any number of dependency issues (including pillow)
Comment From: Tim-Hodge
Also seeing this issue in 4.1.1 with Firefox. PDF exports from a dashboard via UI are working.
Stacktrace:
[2025-01-30 15:06:20,966: ERROR/ForkPoolWorker-1] An unexpected error occurred while executing the report: f79163ce-f368-4041-82c3-c6ed80b8b8d1
Traceback (most recent call last):
File "/app/superset/commands/report/execute.py", line 799, in run
).run()
File "/app/superset/utils/decorators.py", line 266, in wrapped
return on_error(ex)
File "/app/superset/utils/decorators.py", line 236, in on_error
raise ex
File "/app/superset/utils/decorators.py", line 259, in wrapped
result = func(*args, **kwargs)
File "/app/superset/commands/report/execute.py", line 761, in run
).next()
File "/app/superset/commands/report/execute.py", line 629, in next
self.send()
File "/app/superset/commands/report/execute.py", line 527, in send
notification_content = self._get_notification_content()
File "/app/superset/commands/report/execute.py", line 414, in _get_notification_content
pdf_data = self._get_pdf()
File "/app/superset/commands/report/execute.py", line 281, in _get_pdf
pdf = build_pdf_from_screenshots(screenshots)
File "/app/superset/utils/pdf.py", line 34, in build_pdf_from_screenshots
img = Image.open(BytesIO(snap))
NameError: name 'Image' is not defined. Did you mean: 'images'?
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/app/superset/tasks/scheduler.py", line 95, in execute
).run()
File "/app/superset/utils/decorators.py", line 266, in wrapped
return on_error(ex)
File "/app/superset/utils/decorators.py", line 236, in on_error
raise ex
File "/app/superset/utils/decorators.py", line 259, in wrapped
result = func(*args, **kwargs)
File "/app/superset/commands/report/execute.py", line 803, in run
raise ReportScheduleUnexpectedError(str(ex)) from ex
superset.commands.report.exceptions.ReportScheduleUnexpectedError: name 'Image' is not defined
Comment From: Tim-Hodge
Installing pillow==10.3.0
to my custom docker image solved the issue. Was pillow purposefully removed to slim down the image? If so it would be great to update the docs to mention this installation requirement.
Comment From: sfirke
I would guess that's why it was removed from the lean
/ "production" image. I agree it should be added to the Alerts & Reports docs.
FWIW I have just switched my alerts / reports to use Playwright instead of Selenium, using a feature flag. Since then, without pillow
in my image, I still get this notice in the logs:
superset_init | 2025-03-13 16:21:03,246:INFO:superset.utils.screenshots:No PIL installation found
superset_init | 2025-03-13 16:21:03,871:INFO:superset.utils.pdf:No PIL installation found
But reporting succeeds anyway. I wonder if many orgs have started using Playwright and thus don't perceive this issue.
Comment From: sfirke
To close this issue, let's add a mention of this to the Alerts & Reports docs.
Comment From: rusackas
Looks like @sfirke added this to the docs already. Thanks! Closing :)