i discovered this while using fig = px.choropleth(...), fig.write_image(...), which used to work fine and then broke on a machine. i switched to go.Choropleth where the write_image works, but if i import plotly.express without even using it, kaleido breaks again with same error message. on another machine, plotly.express does not break kaleido. but i cannot tell what the kaleido subprocess is depending on.
sample code followed by error message.
# rather than import plotly.express as px, and using px.data which breaks same as next import
import plotly.data as data
# commenting out the next import removes the issue, even though i do not USE choropleth
from plotly.express import choropleth
from plotly import graph_objs as go
df = data.election()
geojson = data.election_geojson()
colorscales = [
((0.0, '#636efa'), (1.0, '#636efa')),
((0.0, '#EF553B'), (1.0, '#EF553B')),
((0.0, '#00cc96'), (1.0, '#00cc96'))
]
fig = go.Figure()
for i, winner in enumerate(df['winner'].unique()):
dfp = df[df['winner'] == winner]
fig.add_choropleth(geojson=geojson, locations=dfp['district'],
z=[i, ] * len(dfp), featureidkey="properties.district",
showlegend=True, name=winner,
colorscale=colorscales[i], showscale=False)
fig.update_layout(margin={"r": 0, "t": 0, "l": 0, "b": 0},
mapbox=dict(style="carto-positron", zoom=9,
center={"lat": 45.5517, "lon": -73.7073},))
fig.write_image('test.png')
===================
les@embedded:~/Desktop/Projects/COVID-19$ python3 -O discrete.py
Traceback (most recent call last):
File "/home/les/Desktop/Projects/COVID-19/discrete.py", line 73, in
fig.write_image('test.png')
File "/home/les/.local/lib/python3.10/site-packages/plotly/basedatatypes.py", line 3829, in write_image
return pio.write_image(self, *args, **kwargs)
File "/home/les/.local/lib/python3.10/site-packages/plotly/io/_kaleido.py", line 267, in write_image
img_data = to_image(
File "/home/les/.local/lib/python3.10/site-packages/plotly/io/_kaleido.py", line 144, in to_image
img_bytes = scope.transform(
File "/home/les/.local/lib/python3.10/site-packages/kaleido/scopes/plotly.py", line 153, in transform
response = self._perform_transform(
File "/home/les/.local/lib/python3.10/site-packages/kaleido/scopes/base.py", line 293, in _perform_transform
self._ensure_kaleido()
File "/home/les/.local/lib/python3.10/site-packages/kaleido/scopes/base.py", line 198, in _ensure_kaleido
raise ValueError(message)
ValueError: Failed to start Kaleido subprocess. Error stream:
[1116/142140.367153:WARNING:resource_bundle.cc(431)] locale_file_path.empty() for locale
[1116/142140.560349:WARNING:resource_bundle.cc(431)] locale_file_path.empty() for locale
[1116/142140.560364:WARNING:resource_bundle.cc(431)] locale_file_path.empty() for locale
[1116/142141.753919:WARNING:resource_bundle.cc(431)] locale_file_path.empty() for locale
[1116/142142.946569:FATAL:platform_font_skia.cc(97)] Check failed: InitDefaultFont(). Could not find the default font
#0 0x55f9a4f90d79 base::debug::CollectStackTrace()
#1 0x55f9a4f0e633 base::debug::StackTrace::StackTrace()
#2 0x55f9a4f1e15f logging::LogMessage::~LogMessage()
#3 0x55f9a4f1ecde logging::LogMessage::~LogMessage()
#4 0x55f9a583a0ff gfx::PlatformFontSkia::PlatformFontSkia()
#5 0x55f9a583b83b gfx::PlatformFont::CreateDefault()
#6 0x55f9a583161e gfx::Font::Font()
#7 0x55f9a3c7cae3 content::RenderViewHostImpl::CreateRenderView()
#8 0x55f9a3de31ed content::WebContentsImpl::CreateRenderViewForRenderManager()
#9 0x55f9a3c551c7 content::RenderFrameHostManager::ReinitializeRenderFrame()
#10 0x55f9a3c54914 content::RenderFrameHostManager::GetFrameHostForNavigation()
#11 0x55f9a3c542a9 content::RenderFrameHostManager::DidCreateNavigationRequest()
#12 0x55f9a3b976b8 content::FrameTreeNode::CreatedNavigationRequest()
#13 0x55f9a3c1ef4b content::Navigator::Navigate()
#14 0x55f9a3bf61f7 content::NavigationControllerImpl::NavigateWithoutEntry()
#15 0x55f9a3bf5cdf content::NavigationControllerImpl::LoadURLWithParams()
#16 0x55f9a63eee12 headless::HeadlessWebContentsImpl::Create()
#17 0x55f9a52727b7 headless::HeadlessBrowserContextImpl::CreateWebContents()
#18 0x55f9a2ce5a66 OnHeadlessBrowserStarted()
#19 0x55f9a5274033 headless::HeadlessBrowserImpl::RunOnStartCallback()
#20 0x55f9a5275212 headless::HeadlessBrowserMainParts::PreMainMessageLoopRun()
#21 0x55f9a3924dd6 content::BrowserMainLoop::PreMainMessageLoopRun()
#22 0x55f9a3d75413 content::StartupTaskRunner::RunAllTasksNow()
#23 0x55f9a3923dd7 content::BrowserMainLoop::CreateStartupTasks()
#24 0x55f9a3926588 content::BrowserMainRunnerImpl::Initialize()
#25 0x55f9a63f87b7 headless::HeadlessContentMainDelegate::RunProcess()
#26 0x55f9a4c77f3e content::ContentMainRunnerImpl::RunServiceManager()
#27 0x55f9a4c77b76 content::ContentMainRunnerImpl::Run()
#28 0x55f9a4c75374 content::RunContentProcess()
#29 0x55f9a4c75cfc content::ContentMain()
#30 0x55f9a4cc7182 headless::(anonymous namespace)::RunContentMain()
#31 0x55f9a4cc7025 headless::HeadlessBrowserMain()
#32 0x55f9a2ce5fa8 main
#33 0x7ff8e9601d90 (/usr/lib/x86_64-linux-gnu/libc.so.6+0x29d8f)
#34 0x7ff8e9601e40 __libc_start_main
#35 0x55f9a2cdf3ea _start
Received signal 6
#0 0x55f9a4f90d79 base::debug::CollectStackTrace()
#1 0x55f9a4f0e633 base::debug::StackTrace::StackTrace()
#2 0x55f9a4f9095b base::debug::(anonymous namespace)::StackDumpSignalHandler()
#3 0x7ff8e961a520 (/usr/lib/x86_64-linux-gnu/libc.so.6+0x4251f)
#4 0x7ff8e966ea7c pthread_kill
#5 0x7ff8e961a476 raise
#6 0x7ff8e96007f3 abort
#7 0x55f9a4f8f8f5 base::debug::BreakDebugger()
#8 0x55f9a4f1e5b2 logging::LogMessage::~LogMessage()
#9 0x55f9a4f1ecde logging::LogMessage::~LogMessage()
#10 0x55f9a583a0ff gfx::PlatformFontSkia::PlatformFontSkia()
#11 0x55f9a583b83b gfx::PlatformFont::CreateDefault()
#12 0x55f9a583161e gfx::Font::Font()
#13 0x55f9a3c7cae3 content::RenderViewHostImpl::CreateRenderView()
#14 0x55f9a3de31ed content::WebContentsImpl::CreateRenderViewForRenderManager()
#15 0x55f9a3c551c7 content::RenderFrameHostManager::ReinitializeRenderFrame()
#16 0x55f9a3c54914 content::RenderFrameHostManager::GetFrameHostForNavigation()
#17 0x55f9a3c542a9 content::RenderFrameHostManager::DidCreateNavigationRequest()
#18 0x55f9a3b976b8 content::FrameTreeNode::CreatedNavigationRequest()
#19 0x55f9a3c1ef4b content::Navigator::Navigate()
#20 0x55f9a3bf61f7 content::NavigationControllerImpl::NavigateWithoutEntry()
#21 0x55f9a3bf5cdf content::NavigationControllerImpl::LoadURLWithParams()
#22 0x55f9a63eee12 headless::HeadlessWebContentsImpl::Create()
#23 0x55f9a52727b7 headless::HeadlessBrowserContextImpl::CreateWebContents()
#24 0x55f9a2ce5a66 OnHeadlessBrowserStarted()
#25 0x55f9a5274033 headless::HeadlessBrowserImpl::RunOnStartCallback()
#26 0x55f9a5275212 headless::HeadlessBrowserMainParts::PreMainMessageLoopRun()
#27 0x55f9a3924dd6 content::BrowserMainLoop::PreMainMessageLoopRun()
#28 0x55f9a3d75413 content::StartupTaskRunner::RunAllTasksNow()
#29 0x55f9a3923dd7 content::BrowserMainLoop::CreateStartupTasks()
#30 0x55f9a3926588 content::BrowserMainRunnerImpl::Initialize()
#31 0x55f9a63f87b7 headless::HeadlessContentMainDelegate::RunProcess()
#32 0x55f9a4c77f3e content::ContentMainRunnerImpl::RunServiceManager()
#33 0x55f9a4c77b76 content::ContentMainRunnerImpl::Run()
#34 0x55f9a4c75374 content::RunContentProcess()
#35 0x55f9a4c75cfc content::ContentMain()
#36 0x55f9a4cc7182 headless::(anonymous namespace)::RunContentMain()
#37 0x55f9a4cc7025 headless::HeadlessBrowserMain()
#38 0x55f9a2ce5fa8 main
#39 0x7ff8e9601d90 (/usr/lib/x86_64-linux-gnu/libc.so.6+0x29d8f)
#40 0x7ff8e9601e40 __libc_start_main
#41 0x55f9a2cdf3ea _start
r8: 00007ffe2c5406a0 r9: 0000000000000000 r10: 0000000000000008 r11: 0000000000000246
r12: 0000000000000006 r13: 0000000000000016 r14: 00001199ff661510 r15: 00001199ff661518
di: 000000000001ad7d si: 000000000001ad7d bp: 000000000001ad7d bx: 00007ff8ea7f9e00
dx: 0000000000000006 ax: 0000000000000000 cx: 00007ff8e966ea7c sp: 00007ffe2c5405d0
ip: 00007ff8e966ea7c efl: 0000000000000246 cgf: 002b000000000033 erf: 0000000000000000
trp: 0000000000000000 msk: 0000000000000000 cr2: 0000000000000000
[end of stack trace]
Calling _exit(1). Core file will not be generated.
i discovered this while using fig = px.choropleth(...), fig.write_image(...), which used to work fine and then broke on a machine. i switched to go.Choropleth where the write_image works, but if i import plotly.express without even using it, kaleido breaks again with same error message. on another machine, plotly.express does not break kaleido. but i cannot tell what the kaleido subprocess is depending on.
sample code followed by error message.
===================
les@embedded:~/Desktop/Projects/COVID-19$ python3 -O discrete.py
Traceback (most recent call last):
File "/home/les/Desktop/Projects/COVID-19/discrete.py", line 73, in
fig.write_image('test.png')
File "/home/les/.local/lib/python3.10/site-packages/plotly/basedatatypes.py", line 3829, in write_image
return pio.write_image(self, *args, **kwargs)
File "/home/les/.local/lib/python3.10/site-packages/plotly/io/_kaleido.py", line 267, in write_image
img_data = to_image(
File "/home/les/.local/lib/python3.10/site-packages/plotly/io/_kaleido.py", line 144, in to_image
img_bytes = scope.transform(
File "/home/les/.local/lib/python3.10/site-packages/kaleido/scopes/plotly.py", line 153, in transform
response = self._perform_transform(
File "/home/les/.local/lib/python3.10/site-packages/kaleido/scopes/base.py", line 293, in _perform_transform
self._ensure_kaleido()
File "/home/les/.local/lib/python3.10/site-packages/kaleido/scopes/base.py", line 198, in _ensure_kaleido
raise ValueError(message)
ValueError: Failed to start Kaleido subprocess. Error stream:
[1116/142140.367153:WARNING:resource_bundle.cc(431)] locale_file_path.empty() for locale
[1116/142140.560349:WARNING:resource_bundle.cc(431)] locale_file_path.empty() for locale
[1116/142140.560364:WARNING:resource_bundle.cc(431)] locale_file_path.empty() for locale
[1116/142141.753919:WARNING:resource_bundle.cc(431)] locale_file_path.empty() for locale
[1116/142142.946569:FATAL:platform_font_skia.cc(97)] Check failed: InitDefaultFont(). Could not find the default font
#0 0x55f9a4f90d79 base::debug::CollectStackTrace()
#1 0x55f9a4f0e633 base::debug::StackTrace::StackTrace()
#2 0x55f9a4f1e15f logging::LogMessage::~LogMessage()
#3 0x55f9a4f1ecde logging::LogMessage::~LogMessage()
#4 0x55f9a583a0ff gfx::PlatformFontSkia::PlatformFontSkia()
#5 0x55f9a583b83b gfx::PlatformFont::CreateDefault()
#6 0x55f9a583161e gfx::Font::Font()
#7 0x55f9a3c7cae3 content::RenderViewHostImpl::CreateRenderView()
#8 0x55f9a3de31ed content::WebContentsImpl::CreateRenderViewForRenderManager()
#9 0x55f9a3c551c7 content::RenderFrameHostManager::ReinitializeRenderFrame()
#10 0x55f9a3c54914 content::RenderFrameHostManager::GetFrameHostForNavigation()
#11 0x55f9a3c542a9 content::RenderFrameHostManager::DidCreateNavigationRequest()
#12 0x55f9a3b976b8 content::FrameTreeNode::CreatedNavigationRequest()
#13 0x55f9a3c1ef4b content::Navigator::Navigate()
#14 0x55f9a3bf61f7 content::NavigationControllerImpl::NavigateWithoutEntry()
#15 0x55f9a3bf5cdf content::NavigationControllerImpl::LoadURLWithParams()
#16 0x55f9a63eee12 headless::HeadlessWebContentsImpl::Create()
#17 0x55f9a52727b7 headless::HeadlessBrowserContextImpl::CreateWebContents()
#18 0x55f9a2ce5a66 OnHeadlessBrowserStarted()
#19 0x55f9a5274033 headless::HeadlessBrowserImpl::RunOnStartCallback()
#20 0x55f9a5275212 headless::HeadlessBrowserMainParts::PreMainMessageLoopRun()
#21 0x55f9a3924dd6 content::BrowserMainLoop::PreMainMessageLoopRun()
#22 0x55f9a3d75413 content::StartupTaskRunner::RunAllTasksNow()
#23 0x55f9a3923dd7 content::BrowserMainLoop::CreateStartupTasks()
#24 0x55f9a3926588 content::BrowserMainRunnerImpl::Initialize()
#25 0x55f9a63f87b7 headless::HeadlessContentMainDelegate::RunProcess()
#26 0x55f9a4c77f3e content::ContentMainRunnerImpl::RunServiceManager()
#27 0x55f9a4c77b76 content::ContentMainRunnerImpl::Run()
#28 0x55f9a4c75374 content::RunContentProcess()
#29 0x55f9a4c75cfc content::ContentMain()
#30 0x55f9a4cc7182 headless::(anonymous namespace)::RunContentMain()
#31 0x55f9a4cc7025 headless::HeadlessBrowserMain()
#32 0x55f9a2ce5fa8 main
#33 0x7ff8e9601d90 (/usr/lib/x86_64-linux-gnu/libc.so.6+0x29d8f)
#34 0x7ff8e9601e40 __libc_start_main
#35 0x55f9a2cdf3ea _start
Received signal 6
#0 0x55f9a4f90d79 base::debug::CollectStackTrace()
#1 0x55f9a4f0e633 base::debug::StackTrace::StackTrace()
#2 0x55f9a4f9095b base::debug::(anonymous namespace)::StackDumpSignalHandler()
#3 0x7ff8e961a520 (/usr/lib/x86_64-linux-gnu/libc.so.6+0x4251f)
#4 0x7ff8e966ea7c pthread_kill
#5 0x7ff8e961a476 raise
#6 0x7ff8e96007f3 abort
#7 0x55f9a4f8f8f5 base::debug::BreakDebugger()
#8 0x55f9a4f1e5b2 logging::LogMessage::~LogMessage()
#9 0x55f9a4f1ecde logging::LogMessage::~LogMessage()
#10 0x55f9a583a0ff gfx::PlatformFontSkia::PlatformFontSkia()
#11 0x55f9a583b83b gfx::PlatformFont::CreateDefault()
#12 0x55f9a583161e gfx::Font::Font()
#13 0x55f9a3c7cae3 content::RenderViewHostImpl::CreateRenderView()
#14 0x55f9a3de31ed content::WebContentsImpl::CreateRenderViewForRenderManager()
#15 0x55f9a3c551c7 content::RenderFrameHostManager::ReinitializeRenderFrame()
#16 0x55f9a3c54914 content::RenderFrameHostManager::GetFrameHostForNavigation()
#17 0x55f9a3c542a9 content::RenderFrameHostManager::DidCreateNavigationRequest()
#18 0x55f9a3b976b8 content::FrameTreeNode::CreatedNavigationRequest()
#19 0x55f9a3c1ef4b content::Navigator::Navigate()
#20 0x55f9a3bf61f7 content::NavigationControllerImpl::NavigateWithoutEntry()
#21 0x55f9a3bf5cdf content::NavigationControllerImpl::LoadURLWithParams()
#22 0x55f9a63eee12 headless::HeadlessWebContentsImpl::Create()
#23 0x55f9a52727b7 headless::HeadlessBrowserContextImpl::CreateWebContents()
#24 0x55f9a2ce5a66 OnHeadlessBrowserStarted()
#25 0x55f9a5274033 headless::HeadlessBrowserImpl::RunOnStartCallback()
#26 0x55f9a5275212 headless::HeadlessBrowserMainParts::PreMainMessageLoopRun()
#27 0x55f9a3924dd6 content::BrowserMainLoop::PreMainMessageLoopRun()
#28 0x55f9a3d75413 content::StartupTaskRunner::RunAllTasksNow()
#29 0x55f9a3923dd7 content::BrowserMainLoop::CreateStartupTasks()
#30 0x55f9a3926588 content::BrowserMainRunnerImpl::Initialize()
#31 0x55f9a63f87b7 headless::HeadlessContentMainDelegate::RunProcess()
#32 0x55f9a4c77f3e content::ContentMainRunnerImpl::RunServiceManager()
#33 0x55f9a4c77b76 content::ContentMainRunnerImpl::Run()
#34 0x55f9a4c75374 content::RunContentProcess()
#35 0x55f9a4c75cfc content::ContentMain()
#36 0x55f9a4cc7182 headless::(anonymous namespace)::RunContentMain()
#37 0x55f9a4cc7025 headless::HeadlessBrowserMain()
#38 0x55f9a2ce5fa8 main
#39 0x7ff8e9601d90 (/usr/lib/x86_64-linux-gnu/libc.so.6+0x29d8f)
#40 0x7ff8e9601e40 __libc_start_main
#41 0x55f9a2cdf3ea _start
r8: 00007ffe2c5406a0 r9: 0000000000000000 r10: 0000000000000008 r11: 0000000000000246
r12: 0000000000000006 r13: 0000000000000016 r14: 00001199ff661510 r15: 00001199ff661518
di: 000000000001ad7d si: 000000000001ad7d bp: 000000000001ad7d bx: 00007ff8ea7f9e00
dx: 0000000000000006 ax: 0000000000000000 cx: 00007ff8e966ea7c sp: 00007ffe2c5405d0
ip: 00007ff8e966ea7c efl: 0000000000000246 cgf: 002b000000000033 erf: 0000000000000000
trp: 0000000000000000 msk: 0000000000000000 cr2: 0000000000000000
[end of stack trace]
Calling _exit(1). Core file will not be generated.