
Hello,
I’ve been experiencing some difficulties with Bokeh’s get_screenshot_as_png function.
It seems that in Bokeh 2.3.3, the dir parameter is not set in bokeh/io/expoty.py/ file under the class _TempFile init function, and the default TMPDIR is automatically assigned to a location visible to the web driver. In this case, the function works as expected.
However, in newer versions of Bokeh, the dir parameter is set to os.getcwd(), which the web driver cannot access.
MRE
from bokeh.plotting import figure
from bokeh.io.export import get_screenshot_as_png
import chromedriver_autoinstaller
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
p = figure()
p.circle([0], [0])
chromedriver_autoinstaller.install()
chrome_options = Options()
chrome_options.add_argument("--headless")
chrome_options.add_argument("--no-sandbox")
chrome_options.add_argument("--disable-gpu")
chrome_options.add_argument("--disable-software-rasterizer")
chrome_driver = webdriver.Chrome(options=chrome_options)
image = get_screenshot_as_png(
p,
driver=chrome_driver,
)
image.save(p, 'png', optimize=True)
In the code above, one can stop the code at chrome_driver = webdriver.Chrome(options=chrome_options), type chrome_driver.title and see that the property is empty.
I am working on macOS with M1 chip and have cleared permissions to the app folder. In addition, I have searched online for discussions or solutions related to this topic, but I couldn’t find any.
Has anyone else encountered this issue? If so, do you have any suggestions on how to resolve it? I would greatly appreciate any guidance or insights on this matter.
Thank you in advance for your help!
Best regards,
Ofir

