Skip to content
This repository has been archived by the owner on Apr 9, 2024. It is now read-only.

Unable to save to png / svg with Selenium with chrome driver on Ubuntu 20.04 and Python 3.8.10 #101

Closed
fconil opened this issue Feb 8, 2022 · 6 comments

Comments

@fconil
Copy link

fconil commented Feb 8, 2022

Hi everyone,

I am using selenium and I get a traceback when I try to save my chart to a png / svg file with chrome driver.

I get a selenium.common.exceptions.WebDriverException: Message: unknown error: DevToolsActivePort file doesn't exist error

The chart is successfully saved with geckodriver.

The drivers are in my virtualenv "bin" folder, so they are in the path.

My code is the following : https://gist.github.com/fconil/b75c8eef479bb205ff226a13f0aeac62

I noticed there were many DevToolsActivePort issues on Selenium : https://github.com/SeleniumHQ/selenium/issues?q=is%3Aissue+DevToolsActivePort+is%3Aclosed

Regards

@jakevdp
Copy link
Member

jakevdp commented Feb 8, 2022

Sorry this isn't working for you.

https://stackoverflow.com/q/50642308 suggests that this might be due to running selenium as the root user, and can be remedied by running from another user account.

@fconil
Copy link
Author

fconil commented Feb 8, 2022

Fortunately, Firefox webdriver works :)

I am using Selenium 4.1.0 - (2).

Chrome binaries are installed by apt / snap in /snap/bin and belong to root. This is not a problem for Firefox, I admit I am confused by this thread.

I did not found how to "run Chrome as a regular user", I may be missing something.

Now I am trying to simply instantiate a chrome webdriver but I still get a WebDriverException: Message: unknown error: DevToolsActivePort file doesn't exist error message, so I have asked the Selenium project for an advice : SeleniumHQ/selenium#10341.

Thanks Jake for your prompt reply and for your help.

@jakevdp
Copy link
Member

jakevdp commented Feb 8, 2022

I have to admit that selenium remains mostly mysterious to me. I cobbled together this package in a way that seems to work much of the time, but I apologize that I can't be of more help in debugging selenium issues.

@fconil
Copy link
Author

fconil commented Feb 9, 2022

I try to dig the Selenium / Chromium problem and I found some information that I shared in the Selenium issue : SeleniumHQ/selenium#10341 (comment)

I noticed that on Ubuntu, Chromium was installed with a chromedriver (chromium.chromedriver) with Snap in /snap/bin/.

Unfortunately, it is not found automatically and I had to specify the executable_path.

Don't apologize, it is not an Altair issue in fact :)

@ehansis
Copy link

ehansis commented Feb 21, 2022

I just stumbled upon the same issue (DevToolsActivePort file doesn't exist). This indeed seems to be an issue with the Snap way of installing Chromium. I found some relevant information here: https://stackoverflow.com/a/65121582/5839193

What helped for me was adding an option .add_argument('--user-data-dir=/home/me/foo') to point the webdriver to use a different directory for its config files.

Using the original chromedriver installed with Snap didn't help but resulted in an error Service chromedriver unexpectedly exited. Status code was: 64 (which I didn't investigate further).

All these are not really issues of altair_saver... but what would help is having some way of passing additional options to the Webdriver when it is being instantiated. If I'm not mistaken, there seems to be an open PR (#69) that has some code for that? (Though, the PR doesn't seem to be ready to merge yet.) Right now I'm resorting to hand-patching the respective file in altair_saver...

@joelostblom
Copy link
Member

Since Altair 5.2, the functionality of Altair Saver is now available in Altair via the vl-convert package. Most of the functionality has been available since 5.0, and the main addition in 5.2 was PDF export. See the docs on how to save charts for more details

We are going to archive this repo, so I'm closing all the open issues and PRs before doing so. Try out the new options for saving charts mentioned above and if you run into issues, please open an issue directly in the altair or vl-convert repo.

@joelostblom joelostblom closed this as not planned Won't fix, can't repro, duplicate, stale Mar 30, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants