1

We're currently unable to use plotly write_image. A stacktrace is thrown and the terminal completely hangs (it doesn't even respond to control + C). This is related to kaleido and I've seen a number of other posts recommending to downgrade to kaleido 0.1.0, however this version is now almost 5 years old and it feels like there must be a more current solution.

Our installation is python 3.11.13, kaleido 1.1.0, plotly 6.3.0. We're running a very simple test with the following code:

import plotly.express as px
import pandas as pd

out_dir = "C:/Temp"

xs = pd.date_range('01-01-2025', '02-01-2025')
ys = range(len(xs))

fig = px.line(x=xs,y=ys)

fig.write_html( f'{out_dir}/test1.html')
fig.write_image(f'{out_dir}/test1.png', width=fig.layout.width, height=fig.layout.height)

The write_html works fine, however the write_image produces a large stacktrace, the last bit being:

  File "C:\Apps\Miniconda3\envs\risk311\Lib\site-packages\choreographer\browser_async.py", line 131, in run
    return subprocess.Popen(  # noqa: S603
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Apps\Miniconda3\envs\risk311\Lib\subprocess.py", line 1026, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "C:\Apps\Miniconda3\envs\risk311\Lib\subprocess.py", line 1538, in _execute_child
    hp, ht, pid, tid = _winapi.CreateProcess(executable, args,
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
PermissionError: [WinError 5] Access is denied

At this point the process hangs, and the terminal is frozen. The question is - access is denied to what exactly? I'm running as an administrator, and the write_html works so its not the destination folder ...

Two additional notes - we do NOT have Chrome installed, which (sadly) is needed by kaleido. However, we do have Edge, and from following the documentation, we have properly set the following env variable: BROWSER_PATH="C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe"

Second, this only happens when running a cmd wrapper script to activate the conda environment and run the above python code. If I open a console interactively and manually enter every line of the wrapper and the script above, it runs without problems. We use this wrapper for all of our scheduled jobs without issue, and it is the following:

set BROWSER_PATH="C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe"

set env_name="risk311"
set conda_path="C:\ProgramData\miniconda3"
set env_path="C:\Apps\Miniconda3\envs\risk311"

:: activate env

call %conda_path%\condabin\conda.bat activate %env_name%
%env_path%\python.exe <path to python script>

In both cases I'm running as a local administrator on the server.

I can downgrade kaleido if needed, but was hoping a more current solution might be available - thanks!

2
  • The Plotly reference includes an explanation about kaleido. According to this explanation, kaleido requires Chrome to be installed. For details, please refer to this page. Commented Sep 20 at 2:06
  • Thanks, I did see that, although further down that page, they say other browsers are supported: link unfortunately, that support looks to be incomplete. We block Chrome for security reasons, so that leaves us a bit stuck with this one. Commented Sep 21 at 17:21

1 Answer 1

0

In case it helps anyone, I found the solution to this, which is honestly absurd and I'm a bit embarrassed to admit that I missed it. This bit:

set BROWSER_PATH="C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe"

Needs to be changed to:

set BROWSER_PATH=C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe

Without the quotes. The quotes are correct, as far as Windows / cmd files are concerned, but when that variable gets pulled into the shell and passed down to python it ends up being quoted again, so you get:

os.environ['BROWSER_PATH'] -> '"C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe"'

Notice the additional quotes in there. That path doesn't exist, and so you end up with

[WinError 5] Access is denied

Its a bit unfortunate that you don't get something more descriptive like file XYZ not found, or invalid path XYZ, but so be it ...

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.