Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[BUG] fig.write_image #5436

Open
Open
@zoltek2

Description

@zoltek2

plotly[express, kaleido] v6.5.0
jupyter v1.1.1
winver: 25H2
chrome: v142.0.7444.176

Simple example in jupyter:

import plotly.express as pxdata_canada = px.data.gapminder().query("country == 'Canada'")fig = px.bar(data_canada, x='year', y='pop')fig.show()fig.write_image('fig.svg')

error:

PermissionError Traceback (most recent call last)
Cell In[3], line 1
----> 1 fig.write_image('fig.svg')

File~\OneDrive\Dokumenty\Projekty\Projekt dla DST\Wymiarowanie.venv\Lib\site-packages\plotly\basedatatypes.py:3895, in BaseFigure.write_image(self, *args, **kwargs)
3891 if kwargs.get("engine", None):
3892 warnings.warn(
3893 ENGINE_PARAM_DEPRECATION_MSG, DeprecationWarning, stacklevel=2
3894 )
-> 3895 return pio.write_image(self, *args, **kwargs)

File~\OneDrive\Dokumenty\Projekty\Projekt dla DST\Wymiarowanie.venv\Lib\site-packages\plotly\io_kaleido.py:528, in write_image(fig, file, format, scale, width, height, validate, engine)
524 format = infer_format(path, format)
526 # Request image
527 # Do this first so we don't create a file if image conversion fails
--> 528 img_data = to_image(
529 fig,
530 format=format,
531 scale=scale,
532 width=width,
533 height=height,
534 validate=validate,
535 engine=engine,
536 )
538 # Open file
539 if path is None:
540 # We previously failed to make sense offile as a pathlib object.
541 # Attempt to write tofile as an open file descriptor.

File~\OneDrive\Dokumenty\Projekty\Projekt dla DST\Wymiarowanie.venv\Lib\site-packages\plotly\io_kaleido.py:398, in to_image(fig, format, width, height, scale, validate, engine)
379 width = (
380 width
381 or fig_dict.get("layout", {}).get("width")
(...) 386 or defaults.default_width
387 )
388 height = (
389 height
390 or fig_dict.get("layout", {}).get("height")
(...) 395 or defaults.default_height
396 )
--> 398 img_bytes = kaleido.calc_fig_sync(
399 fig_dict,
400 opts=dict(
401 format=format or defaults.default_format,
402 width=width,
403 height=height,
404 scale=scale or defaults.default_scale,
405 ),
406 topojson=defaults.topojson,
407 kopts=kopts,
408 )
409 except ChromeNotFoundError:
410 raise RuntimeError(PLOTLY_GET_CHROME_ERROR_MSG)

File~\OneDrive\Dokumenty\Projekty\Projekt dla DST\Wymiarowanie.venv\Lib\site-packages\kaleido_init_.py:171, in calc_fig_sync(*args, **kwargs)
169 return _global_server.call_function("calc_fig", *args, **kwargs)
170 else:
--> 171 return _sync_server.oneshot_async_run(calc_fig, args=args, kwargs=kwargs)

File~\OneDrive\Dokumenty\Projekty\Projekt dla DST\Wymiarowanie.venv\Lib\site-packages\kaleido_sync_server.py:131, in oneshot_async_run(func, args, kwargs)
129 res = q.get()
130 if isinstance(res, BaseException):
--> 131 raise res
132 else:
133 return res

File~\OneDrive\Dokumenty\Projekty\Projekt dla DST\Wymiarowanie.venv\Lib\site-packages\kaleido_sync_server.py:122, in oneshot_async_run..run(func, q, *args, **kwargs)
119 def run(func, q, *args, **kwargs):
120 # func is a closure
121 try:
--> 122 q.put(asyncio.run(func(*args, **kwargs)))
123 except BaseException as e: # noqa: BLE001
124 q.put(e)

File~\AppData\Roaming\uv\python\cpython-3.12.8-windows-x86_64-none\Lib\asyncio\runners.py:194, in run(main, debug, loop_factory)
190 raise RuntimeError(
191 "asyncio.run() cannot be called from a running event loop")
193 with Runner(debug=debug, loop_factory=loop_factory) as runner:
--> 194 return runner.run(main)

File~\AppData\Roaming\uv\python\cpython-3.12.8-windows-x86_64-none\Lib\asyncio\runners.py:118, in Runner.run(self, coro, context)
116 self._interrupt_count = 0
117 try:
--> 118 return self._loop.run_until_complete(task)
119 except exceptions.CancelledError:
120 if self._interrupt_count > 0:

File~\AppData\Roaming\uv\python\cpython-3.12.8-windows-x86_64-none\Lib\asyncio\base_events.py:686, in BaseEventLoop.run_until_complete(self, future)
683 if not future.done():
684 raise RuntimeError('Event loop stopped before Future completed.')
--> 686 return future.result()

File~\OneDrive\Dokumenty\Projekty\Projekt dla DST\Wymiarowanie.venv\Lib\site-packages\kaleido_init_.py:101, in calc_fig(fig, path, opts, topojson, kopts)
99 kopts = kopts or {}
100 kopts["n"] = 1 # should we force this?
--> 101 async with Kaleido(**kopts) as k:
102 return await k.calc_fig(
103 fig,
104 path=path,
105 opts=opts,
106 topojson=topojson,
107 )

File~\OneDrive\Dokumenty\Projekty\Projekt dla DST\Wymiarowanie.venv\Lib\site-packages\choreographer\browser_async.py:187, in Browser.aenter(self)
185 async defaenter(self) -> Self:
186 """Open browser as context to launch on entry and close on exit."""
--> 187 await self.open()
188 return self

File~\OneDrive\Dokumenty\Projekty\Projekt dla DST\Wymiarowanie.venv\Lib\site-packages\kaleido\kaleido.py:198, in Kaleido.open(self)
196 page = PageGenerator(plotly=self._plotlyjs, mathjax=self._mathjax)
197 page.generate_index(index)
--> 198 await super().open()

File~\OneDrive\Dokumenty\Projekty\Projekt dla DST\Wymiarowanie.venv\Lib\site-packages\choreographer\browser_async.py:150, in Browser.open(self)
148 _logger.debug("Trying to open browser.")
149 loop = asyncio.get_running_loop()
--> 150 self.subprocess = await loop.run_in_executor(
151 self._process_executor,
152 run,
153 )
155 super().init("0", self._broker)
156 self._add_session(Session("", self._broker))

File~\OneDrive\Dokumenty\Projekty\Projekt dla DST\Wymiarowanie.venv\Lib\site-packages\choreographer\utils_manual_thread_pool.py:37, in ManualThreadExecutor._worker(self)
35 if fut.set_running_or_notify_cancel():
36 try:
---> 37 res = fn(*args, **kwargs)
38 except BaseException as e: # noqa: BLE001 yes we catch and set
39 fut.set_exception(e)

File~\OneDrive\Dokumenty\Projekty\Projekt dla DST\Wymiarowanie.venv\Lib\site-packages\choreographer\browser_async.py:141, in Browser.open..run()
139 env = self._browser_impl.get_env()
140 args = self._browser_impl.get_popen_args()
--> 141 return subprocess.Popen( # noqa: S603
142 cli,
143 stderr=stderr,
144 env=env,
145 **args,
146 )

File~\AppData\Roaming\uv\python\cpython-3.12.8-windows-x86_64-none\Lib\subprocess.py:1026, in Popen.init(self, args, bufsize, executable, stdin, stdout, stderr, preexec_fn, close_fds, shell, cwd, env, universal_newlines, startupinfo, creationflags, restore_signals, start_new_session, pass_fds, user, group, extra_groups, encoding, errors, text, umask, pipesize, process_group)
1022 if self.text_mode:
1023 self.stderr = io.TextIOWrapper(self.stderr,
1024 encoding=encoding, errors=errors)
-> 1026 self._execute_child(args, executable, preexec_fn, close_fds,
1027 pass_fds, cwd, env,
1028 startupinfo, creationflags, shell,
1029 p2cread, p2cwrite,
1030 c2pread, c2pwrite,
1031 errread, errwrite,
1032 restore_signals,
1033 gid, gids, uid, umask,
1034 start_new_session, process_group)
1035 except:
1036 # Cleanup if the child failed starting.
1037 for f in filter(None, (self.stdin, self.stdout, self.stderr)):

File~\AppData\Roaming\uv\python\cpython-3.12.8-windows-x86_64-none\Lib\subprocess.py:1538, in Popen._execute_child(self, args, executable, preexec_fn, close_fds, pass_fds, cwd, env, startupinfo, creationflags, shell, p2cread, p2cwrite, c2pread, c2pwrite, errread, errwrite, unused_restore_signals, unused_gid, unused_gids, unused_uid, unused_umask, unused_start_new_session, unused_process_group)
1536 # Start the process
1537 try:
-> 1538 hp, ht, pid, tid = _winapi.CreateProcess(executable, args,
1539 # no special security
1540 None, None,
1541 int(not close_fds),
1542 creationflags,
1543 env,
1544 cwd,
1545 startupinfo)
1546 finally:
1547 # Child is launched. Close the parent's copy of those pipe
1548 # handles that only the child should have open. You need
(...) 1551 # pipe will not close when the child process exits and the
1552 # ReadFile will hang.
1553 self._close_pipe_fds(p2cread, p2cwrite,
1554 c2pread, c2pwrite,
1555 errread, errwrite)

PermissionError: [WinError 5] Odmowa dostępu

After adding the system variable:
BROWSER_PATH=C:\Program Files\Google\Chrome\Application\chrome.exe
2025-11-27 17:13:14,720 - kaleido.kaleido - DEBUG - Successfully registered PlotlyJSONEncoder.
2025-11-27 17:13:14,724 - asyncio - DEBUG - Using proactor: IocpProactor
2025-11-27 17:13:14,725 - kaleido.kaleido - DEBUG - Timeout: 90
2025-11-27 17:13:14,725 - choreographer.browser_async - DEBUG - Attempting to open new browser.
2025-11-27 17:13:14,725 - choreographer.browsers.chromium - INFO - Chromium init'ed with kwargs {}
2025-11-27 17:13:14,725 - choreographer.browsers.chromium - DEBUG - Looking for a chrome browser.
2025-11-27 17:13:14,726 - root - DEBUG - Looking for browser, skipping local? False
2025-11-27 17:13:14,734 - root - DEBUG - Looking for at local chrome download path: C:\Users\jaros\OneDrive\Dokumenty\Projekty\Projekt dla DST\Wymiarowanie.venv\Lib\site-packages\choreographer\cli\browser_exe\chrome-win64\chrome.exe
2025-11-27 17:13:14,740 - root - DEBUG - Local chrome not found at path: C:\Users\jaros\OneDrive\Dokumenty\Projekty\Projekt dla DST\Wymiarowanie.venv\Lib\site-packages\choreographer\cli\browser_exe\chrome-win64\chrome.exe.
2025-11-27 17:13:14,740 - choreographer.browsers.chromium - INFO - Found chromium path: C:\Program Files\Google\Chrome\Application\chrome.exe
2025-11-27 17:13:14,741 - choreographer.utils._tmpfile - INFO - Temp directory created: C:\Users\jaros\AppData\Local\Temp\tmp7hmuy8xh.
2025-11-27 17:13:14,741 - kaleido._page_generator - DEBUG - Plotly script: ('file:///C:/Users/jaros/OneDrive/Dokumenty/Projekty/Projekt%20dla%20DST/Wymiarowanie/.venv/Lib/site-packages/plotly/package_data/plotly.min.js', 'utf-8')
2025-11-27 17:13:14,741 - choreographer.browser_async - INFO - Opening browser.
2025-11-27 17:13:14,742 - choreographer.browser_async - DEBUG - Trying to open browser.
2025-11-27 17:13:14,742 - choreographer.utils._tmpfile - INFO - Temp directory created: C:\Users\jaros\AppData\Local\Temp\tmpi5nqpj1m.
2025-11-27 17:13:14,742 - choreographer.browsers.chromium - DEBUG - Checking for libs needed.
2025-11-27 17:13:14,742 - choreographer.browsers.chromium - DEBUG - We're not in linux, so no need for check.
2025-11-27 17:13:14,742 - choreographer.browsers.chromium - INFO - Temporary directory at: C:\Users\jaros\AppData\Local\Temp\tmpi5nqpj1m
2025-11-27 17:13:14,742 - choreographer.browsers.chromium - DEBUG - Returning cli: ['C:\Program Files\Google\Chrome\Application\chrome.exe', '--disable-gpu', '--headless', '--no-sandbox', '--disable-breakpad', '--allow-file-access-from-files', '--enable-logging=stderr', '--user-data-dir=C:\Users\jaros\AppData\Local\Temp\tmpi5nqpj1m', '--no-first-run', '--enable-unsafe-swiftshader', '--disable-dev-shm-usage', '--disable-background-media-suspend', '--disable-lazy-loading', '--disable-background-timer-throttling', '--disable-backgrounding-occluded-windows', '--disable-renderer-backgrounding', '--disable-component-update', '--disable-hang-monitor', '--disable-popup-blocking', '--disable-prompt-on-repost', '--disable-ipc-flooding-protection', '--disable-sync', '--metrics-recording-only', '--password-store=basic', '--use-mock-keychain', '--no-default-browser-check', '--no-process-per-site', '--disable-web-security', '--remote-debugging-pipe', '--remote-debugging-io-pipes=2252,2248']
2025-11-27 17:13:14,742 - choreographer.browsers.chromium - DEBUG - Returning args: {'creationflags': 512, 'close_fds': False}
2025-11-27 17:13:14,745 - choreographer.protocol.devtools_async - DEBUG - Created new target 0.
2025-11-27 17:13:14,745 - choreographer.protocol.devtools_async - DEBUG - New session:
2025-11-27 17:13:14,745 - choreographer.browser_async - DEBUG - Starting watchdog
2025-11-27 17:13:14,745 - choreographer.browser_async - DEBUG - Opening channel.
2025-11-27 17:13:14,745 - choreographer.browser_async - DEBUG - Running read loop
2025-11-27 17:13:14,745 - choreographer.browser_async - DEBUG - Populating Targets
2025-11-27 17:13:14,745 - choreographer.browser_async - DEBUG - In watchdog
2025-11-27 17:13:14,746 - choreographer.protocol.devtools_async - DEBUG - Cmd 'Target.getTargets', param keys '', sessionId ''
2025-11-27 17:13:14,746 - choreographer._brokers._async - DEBUG - Broker writing Target.getTargets with key ('', 0)
2025-11-27 17:13:14,746 - choreographer._brokers._async - DEBUG - Created future: ('', 0)
2025-11-27 17:13:14,746 - choreographer.channels._wire - DEBUG - Serialized: {"id": 0, "meth...et.getTargets"}, size: 40
2025-11-27 17:13:14,746 - choreographer.channels.pipe - DEBUG - Writing message b'{"id": 0, "meth'...b't.getTargets"}\x00', size: 41.
2025-11-27 17:13:14,746 - choreographer.channels.pipe - DEBUG -Wrote 41/41
2025-11-27 17:13:14,804 - choreographer.browser_async - WARNING - Wait expired, Browser is being closed by watchdog.
2025-11-27 17:13:14,804 - choreographer.browser_async - INFO - Closing browser.
2025-11-27 17:13:14,804 - choreographer.browser_async - DEBUG - Starting browser close methods.
2025-11-27 17:13:14,804 - choreographer.browser_async - DEBUG - No _close(), already is closed
2025-11-27 17:13:14,804 - choreographer.browser_async - DEBUG - Browser close methods finished.
2025-11-27 17:13:14,804 - choreographer._brokers._async - DEBUG - Cancelling message futures
2025-11-27 17:13:14,804 - choreographer._brokers._async - DEBUG - Cancelling read task
2025-11-27 17:13:14,804 - choreographer._brokers._async - DEBUG - Cancelling subscription-futures
2025-11-27 17:13:14,804 - choreographer._brokers._async - DEBUG - Cancelling background tasks
2025-11-27 17:13:16,806 - choreographer.browser_async - DEBUG - Broker cleaned up.
2025-11-27 17:13:16,806 - choreographer.browser_async - DEBUG - Logging pipe closed.
2025-11-27 17:13:16,806 - choreographer.channels.pipe - DEBUG - First read in loop: b'{bye}\n'...b'{bye}\n'. size: 6.
2025-11-27 17:13:16,806 - choreographer.channels.pipe - DEBUG - Received b'{bye}\n'. is bye?
2025-11-27 17:13:16,806 - choreographer.channels.pipe - DEBUG - OSError
2025-11-27 17:13:16,806 - choreographer.channels.pipe - DEBUG - Total loops: 1, Final size: 6.
2025-11-27 17:13:16,807 - choreographer.browser_async - DEBUG - Browser channel closed.
2025-11-27 17:13:16,808 - choreographer.utils._tmpfile - INFO - TemporaryDirectory.cleanup() worked.
2025-11-27 17:13:16,808 - choreographer.utils._tmpfile - INFO - shutil.rmtree worked.
2025-11-27 17:13:16,808 - choreographer.browser_async - DEBUG - Browser implementation cleaned up.
2025-11-27 17:13:16,809 - choreographer.utils._tmpfile - INFO - TemporaryDirectory.cleanup() worked.
2025-11-27 17:13:16,809 - choreographer.utils._tmpfile - INFO - shutil.rmtree worked.
2025-11-27 17:13:16,809 - kaleido.kaleido - INFO - Cancelling tasks.
2025-11-27 17:13:16,809 - kaleido.kaleido - INFO - Exiting Kaleido/Choreo
2025-11-27 17:13:16,809 - choreographer._brokers._async - DEBUG - Readloop cancelled
2025-11-27 17:13:16,810 - choreographer.browser_async - DEBUG - Watchdog full shutdown (in finally:)
2025-11-27 17:13:16,832 - choreographer.utils._tmpfile - INFO - TemporaryDirectory.cleanup() worked.
2025-11-27 17:13:16,833 - choreographer.utils._tmpfile - INFO - shutil.rmtree worked.

Error saving image: <Logger ('The browser seemed to close immediately after starting.', 'You can set thelogging.Logger level lower to see more output.', 'You may try installing a known working copy of Chrome by running ', '$ choreo_get_chrome.It may be your browser auto-updated and will now work upon restart. The browser we tried to start is located at C:\Program Files\Google\Chrome\Application\chrome.exe.') (NOTSET)>

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp