Forums

Plotly Kaleido compatibility with Pythonanywhere

Tried to use Plotly Kaleido for static image generation but encountered the error below. Any suggestions?

File "/home/roycechaneu/.virtualenvs/py37/lib/python3.7/site-packages/kaleido/scopes/base.py", line 120, in _ensure_kaleido raise ValueError(message) ValueError: Failed to start Kaleido subprocess. Error stream: [0725/071713.653558:ERROR:stack_trace_posix.cc(663)] Failed to read /proc/self/maps [0725/071713.671309:WARNING:resource_bundle.cc(435)] locale_file_path.empty() for locale [0725/071713.671576:FATAL:zygote_communication_linux.cc(225)] Check failed: base::PathService::Get(base::FILE_EXE, &chrome_path).

It looks like our old virtualisation system is not compatible with that. We have a new one that is experimental and in testing. We can switch your account to use that so you can see if that helps.

hello, i came also to this problem. Can i also be switched to new system ?

Sure, we've switched you over. You will have to stop and restart your consoles / reload your webapp etc for the change to take effect.

Same problem here. May I be also be switched? Thanks!

Sure! That's done now.

I am also facing the same issue, may I also be switched when you have a sec? Thanks

It's done for you. No problem.

May I also switch too? I am having the same problem please

Sure, no problem -- that's done now. As @conrad said earlier, you will have to stop and restart your consoles / reload your webapp etc for the change to take effect.

By restarting my consoles do you mean closing them or just reloading the app?

thanks

restarting your console == you can kill the consoles from the console page by clicking the "x" button, and then starting a new console.

reloading your webapp means hitting the reload webapp button on the webapp page.

helpful, thanks!

Can you do me as well please, trying to use Kaleido too.

@JWDT I enabled new virtualization for you, but your account is still on the old system image.

We can upgrade your system image but one word of warning first -- because changing the system image upgrades a lot of the pre-installed Python packages, any code that you have that relies on those packages might break if it's not compatible with the new versions. Also, because the new image has newer versions of Python, if you have any virtualenvs, you may need to rebuild them. If you're happy to go ahead despite that, just let us know and we'll switch you over.

Hi @fjl - yes please, there's nothing running on the system that matters anyway right now. :-)

@JWDT -- no problem. That's done now.

Please can you migrate me too so I can use Kaleido, thanks

No problem. That's done.

I would also like to use Kaleido. Can my account be migrated too?

Sure, no problem -- that's done now.

Just a note to say that you no longer need to ask to have your system image changed -- you can change it yourself from the "Account" page. There's more information on this help page.

Hi, what would be the new one? I am also trying to generate images using plotly kaleido, and I land in the same issue

I see that in system image there are three choices, not sure which one is the one that make this work?

Dangermouse(current) /earlgrey /fishnchips

Fishandchips is the newest. See the help page.

Great, thank you!

No problem.

hey, same problem here. Can I also be switched to the new system?

That sounds strange -- you're already on the fishnchips system image, and all accounts now have the new virtualization system. Could you copy/paste the exact error that you're getting into a new post here?

Yes of course, so if I do: fig.show() , everything works as expected, but when I try fig.write_image('test.png'), it throws the error below. I tried updating Kaleido but same error. I am running this from a notebook to test with the intention of running the script in a scheduled/always-on task. The exact code works on my own computer.

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-1-975e39b34d61> in <module>
    115         fig.add_vline(x=0,line_color="black")
    116         fig.update_layout(height=1200, width=1000, title_text=stk+name+'\n'+strat,yaxis_zeroline=True, xaxis_zeroline=True)
--> 117         fig.write_image(local_dir+'RV_IV_images/'+file_extension+'/'+file_extension+'_'+stk+'.png')
    118 
    119

~/.local/lib/python3.8/site-packages/plotly/basedatatypes.py in write_image(self, *args, **kwargs)
   3819         import plotly.io as pio
   3820 
-> 3821         return pio.write_image(self, *args, **kwargs)
   3822 
   3823     # Static helpers

~/.local/lib/python3.8/site-packages/plotly/io/_kaleido.py in write_image(fig, file, format, scale, width, height, validate, engine)
    266     # -------------
    267     # Do this first so we don't create a file if image conversion fails
--> 268     img_data = to_image(
    269         fig,
    270         format=format,

~/.local/lib/python3.8/site-packages/plotly/io/_kaleido.py in to_image(fig, format, width, height, scale, validate, engine)
    143     # ---------------
    144     fig_dict = validate_coerce_fig_to_dict(fig, validate)
--> 145     img_bytes = scope.transform(
    146         fig_dict, format=format, width=width, height=height, scale=scale
    147     )

~/.local/lib/python3.8/site-packages/kaleido/scopes/plotly.py in transform(self, figure, format, width, height, scale)
    151         # Transform in using _perform_transform rather than superclass so we can access the full
    152         # response dict, including error codes.
--> 153         response = self._perform_transform(
    154             figure, format=format, width=width, height=height, scale=scale
    155         )

~/.local/lib/python3.8/site-packages/kaleido/scopes/base.py in _perform_transform(self, data, **kwargs)
    291         """
    292         # Ensure that kaleido subprocess is running
--> 293         self._ensure_kaleido()
    294 
    295         # Perform export

~/.local/lib/python3.8/site-packages/kaleido/scopes/base.py in _ensure_kaleido(self)
    196                             self._get_decoded_std_error()
    197                         )
--> 198                         raise ValueError(message)
    199                     else:
    200                         startup_response = json.loads(startup_response_string)

ValueError: Failed to start Kaleido subprocess. Error stream:

[0801/084529.959505:ERROR:stack_trace_posix.cc(662)] Failed to read /proc/self/maps
[0801/084530.019262:WARNING:resource_bundle.cc(431)] locale_file_path.empty() for locale 
[0801/084530.044932:FATAL:zygote_communication_linux.cc(225)] Check failed: base::PathService::Get(base::FILE_EXE, &chrome_path). 
#0 0x55c13b94cd79 <unknown>
#1 0x55c13b8ca633 <unknown>
#2 0x55c13b8da15f <unknown>
#3 0x55c13b8dacde <unknown>
#4 0x55c13a076983 <unknown>
#5 0x55c13a0773c7 <unknown>
#6 0x55c13b63380b <unknown>
#7 0x55c13b631bbc <unknown>
#8 0x55c13b631cfc <unknown>
#9 0x55c13b683182 <unknown>
#10 0x55c13b683025 <unknown>
#11 0x55c1396a1fa8 <unknown>
#12 0x7fc8d7c0a830 <unknown>
#13 0x55c13969b3ea <unknown>

Received signal 6
#0 0x55c13b94cd79 <unknown>
#1 0x55c13b8ca633 <unknown>
#2 0x55c13b94c95b <unknown>
#3 0x7fc8d90c8390 <unknown>
#4 0x7fc8d7c1f428 <unknown>
#5 0x7fc8d7c2102a <unknown>
#6 0x55c13b94b8f5 <unknown>
#7 0x55c13b8da5b2 <unknown>
#8 0x55c13b8dacde <unknown>
#9 0x55c13a076983 <unknown>
#10 0x55c13a0773c7 <unknown>
#11 0x55c13b63380b <unknown>
#12 0x55c13b631bbc <unknown>
#13 0x55c13b631cfc <unknown>
#14 0x55c13b683182 <unknown>
#15 0x55c13b683025 <unknown>
#16 0x55c1396a1fa8 <unknown>
#17 0x7fc8d7c0a830 <unknown>
#18 0x55c13969b3ea <unknown>
  r8: 0000000000000000  r9: 0000000000000000 r10: 0000000000000008 r11: 0000000000000206
 r12: 00007ffdb471e0e0 r13: 000023bddb344dc0 r14: 000023bddb344dd0 r15: 000023bddb344dd8
  di: 00000000001a0395  si: 00000000001a0395  bp: 00007ffdb471d890  bx: 000023bddb344dd8
  dx: 0000000000000006  ax: 0000000000000000  cx: 00007fc8d7c1f428  sp: 00007ffdb471d758
  ip: 00007fc8d7c1f428 efl: 0000000000000206 cgf: 002b000000000033 erf: 0000000000000000
 trp: 0000000000000000 msk: 0000000000000000 cr2: 0000000000000000
[end of stack trace]
Calling _exit(1). Core file will not be generated.

Maybe try to update your system image to glastonbury. You can change it yourself from the "Account" page. There's more information on this help page:.

Unfortunately, after following the guidelines and using the Glastonbury image, I still get this error. I have installed all dependencies and am running the kernel on python 3.9.

Delete your ~/.local/lib/python3.8/ directory and re-install the packages you're using.

I tried that but still the same error, I deleted 3.8 and 3.9 and reinstalled all the packages and it's still throwing the same error

Where do you run that?

At the moment I run out through the IPython Notebook

If you're doing that in a notebook, make sure to kill all processes with "jupyter" in the command from the "Fetch processes" list on the Consoles page and then reload your notebook and try again.

Hi there, unfortunately, I had already tried that. I have deleted all my libraries in 3.8 and 3.9, reinstalled everything and killed all the consoles and processes, changed the system image, started a new notebook entirely , even waited a day and repeated the process and still the same error message.

So it's a different python version and a different Kaleido version now?

Yes and I still have the same issue.

Apologies, I think that my colleagues have missed a point here; the new virtualization system does not work in notebooks yet, and your code will only work in consoles, scheduled/always-on tasks, or in website code.

Once again, sorry that no-one picked up on that earlier.

Great this works now in a prebuilt script. Thank you for the help.