简体   繁体   中英

Bokeh throws a RuntimeError whenever I try to run export_png

I just updated all of my python packages and some of my scripts aren't working properly. Specifically, Bokeh is having issues with the export_png function.

Normally that just saves a copy of my chart to a specific directory. Now I'm getting this error:

Traceback (most recent call last):

  File "C:\Users\ethan\projects\health\chart.py", line 112, in <module>
    p = column(make_chart(False), make_chart(True))

  File "C:\Users\ethan\projects\health\chart.py", line 106, in make_chart
    export_png(p, filename = name + '.png')

  File "C:\ProgramData\Anaconda3\lib\site-packages\bokeh\io\export.py", line 97, in export_png
    image = get_screenshot_as_png(obj, width=width, height=height, driver=webdriver, timeout=timeout)

  File "C:\ProgramData\Anaconda3\lib\site-packages\bokeh\io\export.py", line 201, in get_screenshot_as_png
    web_driver = driver if driver is not None else webdriver_control.get()

  File "C:\ProgramData\Anaconda3\lib\site-packages\bokeh\io\webdriver.py", line 118, in get
    self.current = self.create()

  File "C:\ProgramData\Anaconda3\lib\site-packages\bokeh\io\webdriver.py", line 122, in create
    driver = self._create(kind)

  File "C:\ProgramData\Anaconda3\lib\site-packages\bokeh\io\webdriver.py", line 140, 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'.

Chrome works fine on my computer I'm using it now. I'm not sure why bokeh needs to use a browser for this because I'm just making a png file but is there a way to fix this without installing firefox? I'd prefer to keep using chrome.

I'm not sure why bokeh needs to use a browser for this because I'm just making a png file

That's because in order to create that PNG file, the HTML document created by Bokeh needs to be rendered. Previously, Bokeh was using PhantomJS for that, but that project is now obsolete and unmaintained.

is there a way to fix this without installing firefox?

As the error message says, if you want to use a chromium browser (which Google Chrome is), you have to have chromedriver on your PATH. If you're using conda , you can try to install it via conda install -c conda-forge python-chromedriver-binary within the same environment that you use for Bokeh.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM