Cannot export to png, geckodriver etc ok

import numpy as np
from bokeh.plotting import figure
from bokeh.io import export_png

f = figure()
x = np.linspace(-10, 10, 100)
y = x**2
f.line(x=x, y=y)
export_png(f, filename='out.png')

Fails with import numpy as np
from bokeh.plotting import figure
from bokeh.io import export_png

f = figure()
x = np.linspace(-10, 10, 100)
y = x**2
f.line(x=x, y=y)
export_png(f, filename='out.png')

Name Version Build Channel

geckodriver 0.36.0 hb7e49e0_0 conda-forge
selenium 4.33.0 pyhe01879c_0 conda-forge
firefox 139.0.1 h3e4d06c_0 conda-forge
bokeh 3.4.3 py_0 bokeh

What am I doing wrong?

@dlf it’s not possible to speculate without also having the exact full error you are seeing provided. There was another recent thread regarding a similar issue you may want to check out of info and suggestions: Trying to get export_png to work in Bokeh 3.6.2 on Windows Conda

This code

import numpy as np
from bokeh.plotting import figure
from bokeh.io import export_png

f = figure()
x = np.linspace(-10, 10, 100)
y = x**2
f.line(x=x, y=y)
export_png(f, filename='out.png')

gives this error

  File "/tmp/bokehtest.py", line 9, in <module>
    export_png(f, filename='out.png')
  File "/home/user/miniforge3/envs/bokeh/lib/python3.9/site-packages/bokeh/io/export.py", line 119, in export_png
    image = get_screenshot_as_png(obj, width=width, height=height, scale_factor=scale_factor, driver=webdriver,
  File "/home/user/miniforge3/envs/bokeh/lib/python3.9/site-packages/bokeh/io/export.py", line 274, in get_screenshot_as_png
    web_driver = webdriver_control.get(scale_factor=scale_factor)
  File "/home/user/miniforge3/envs/bokeh/lib/python3.9/site-packages/bokeh/io/webdriver.py", line 176, in get
    self.current = self.create(scale_factor=scale_factor)
  File "/home/user/miniforge3/envs/bokeh/lib/python3.9/site-packages/bokeh/io/webdriver.py", line 180, in create
    driver = self._create(kind, scale_factor=scale_factor)
  File "/home/user/miniforge3/envs/bokeh/lib/python3.9/site-packages/bokeh/io/webdriver.py", line 198, in _create
    raise RuntimeError("Neither firefox and geckodriver nor a variant of chromium browser and " \
RuntimeError: Neither firefox and geckodriver nor a variant of chromium browser and chromedriver are available on system PATH. You can install the former with 'conda install -c conda-forge firefox geckodriver'.

I also tried

from bokeh.io.webdriver import create_firefox_webdriver
create_firefox_webdriver()

and it showed a problem with the proxy.
By setting

no_proxy=localhost,127.0.0.1 

it now hangs in create_firefox_webdriver().

Traceback (most recent call last):
  File "/tmp/bokehtest2.py", line 2, in <module>
    create_firefox_webdriver()
  File "/home/user/miniforge3/envs/bokeh/lib/python3.9/site-packages/bokeh/io/webdriver.py", line 87, in create_firefox_webdriver
    return Firefox(service=service, options=options)
  File "/home/user/miniforge3/envs/bokeh/lib/python3.9/site-packages/selenium/webdriver/firefox/webdriver.py", line 72, in __init__
    super().__init__(command_executor=executor, options=options)
  File "/home/user/miniforge3/envs/bokeh/lib/python3.9/site-packages/selenium/webdriver/remote/webdriver.py", line 257, in __init__
    self.start_session(capabilities)
  File "/home/user/miniforge3/envs/bokeh/lib/python3.9/site-packages/selenium/webdriver/remote/webdriver.py", line 356, in start_session
    response = self.execute(Command.NEW_SESSION, caps)["value"]
  File "/home/user/miniforge3/envs/bokeh/lib/python3.9/site-packages/selenium/webdriver/remote/webdriver.py", line 445, in execute
    response = self.command_executor.execute(driver_command, params)
  File "/home/user/miniforge3/envs/bokeh/lib/python3.9/site-packages/selenium/webdriver/remote/remote_connection.py", line 404, in execute
    return self._request(command_info[0], url, body=data)
  File "/home/user/miniforge3/envs/bokeh/lib/python3.9/site-packages/selenium/webdriver/remote/remote_connection.py", line 428, in _request
    response = self._conn.request(method, url, body=body, headers=headers, timeout=self._client_config.timeout)
  File "/home/user/miniforge3/envs/bokeh/lib/python3.9/site-packages/urllib3/_request_methods.py", line 143, in request
    return self.request_encode_body(
  File "/home/user/miniforge3/envs/bokeh/lib/python3.9/site-packages/urllib3/_request_methods.py", line 278, in request_encode_body
    return self.urlopen(method, url, **extra_kw)
  File "/home/user/miniforge3/envs/bokeh/lib/python3.9/site-packages/urllib3/poolmanager.py", line 443, in urlopen
    response = conn.urlopen(method, u.request_uri, **kw)
  File "/home/user/miniforge3/envs/bokeh/lib/python3.9/site-packages/urllib3/connectionpool.py", line 787, in urlopen
    response = self._make_request(
  File "/home/user/miniforge3/envs/bokeh/lib/python3.9/site-packages/urllib3/connectionpool.py", line 534, in _make_request
    response = conn.getresponse()
  File "/home/user/miniforge3/envs/bokeh/lib/python3.9/site-packages/urllib3/connection.py", line 516, in getresponse
    httplib_response = super().getresponse()
  File "/home/user/miniforge3/envs/bokeh/lib/python3.9/http/client.py", line 1377, in getresponse
    response.begin()
  File "/home/user/miniforge3/envs/bokeh/lib/python3.9/http/client.py", line 320, in begin
    version, status, reason = self._read_status()
  File "/home/user/miniforge3/envs/bokeh/lib/python3.9/http/client.py", line 281, in _read_status
    line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1")
  File "/home/user/miniforge3/envs/bokeh/lib/python3.9/socket.py", line 716, in readinto
    return self._sock.recv_into(b)
KeyboardInterrupt

The same is true for the previous export_png example.

What output do you get if you just run geckodriver manually at the command line? Do things works if you try chrome + chromedriver instead?

running geckodriver gives

1750986066690 geckodriver INFO Listening on 127.0.0.1:4444

I solved by deleting snap’s firefox, and having firefox only inside conda. It seems having the external firefox created the problem.

chrome and chromedriver are installed

from selenium import webdriver
webdriver.Chrome()

worked, but that was not enough for bokeh to work.