leoncvlt / blinkist-scraper

📚 Python tool to download book summaries and audio from Blinkist.com, and generate some pretty output
191 stars 35 forks source link

Chromedriver issues on raspberry - unknown error: DevToolsActivePort file doesn't exist #28

Closed sasagr closed 3 years ago

sasagr commented 4 years ago

I m trying to run it on my raspberry pi4 but it seems that it does not like the chromedriver. I had to arg the chromedriver location and I also tried with the latest version from https://github.com/electron/electron/releases but with same results.

Any idea pls?

pi@raspberrypi:~/blinkist-scraper $ python3 blinkistscraper/main.py user pass --book https://www.blinkist.com/en/nc/reader/on-saudi-arabia-en --chromedriver /usr/bin/chromedriver [18:30:10] INFO Starting scrape run... [18:30:10] INFO Initialising chromedriver at /usr/bin/chromedriver... Traceback (most recent call last): File "blinkistscraper/main.py", line 340, in main() File "blinkistscraper/main.py", line 279, in main chromedriver_path=args.chromedriver, File "/home/pi/blinkist-scraper/blinkistscraper/scraper.py", line 81, in initialize_driver options=chrome_options, File "/home/pi/.local/lib/python3.7/site-packages/seleniumwire/webdriver/browser.py", line 86, in init super().init(*args, **kwargs) File "/usr/local/lib/python3.7/dist-packages/selenium/webdriver/chrome/webdriver.py", line 81, in init desired_capabilities=desired_capabilities) File "/usr/local/lib/python3.7/dist-packages/selenium/webdriver/remote/webdriver.py", line 157, in init self.start_session(capabilities, browser_profile) File "/usr/local/lib/python3.7/dist-packages/selenium/webdriver/remote/webdriver.py", line 252, in start_session response = self.execute(Command.NEW_SESSION, parameters) File "/usr/local/lib/python3.7/dist-packages/selenium/webdriver/remote/webdriver.py", line 321, in execute self.error_handler.check_response(response) File "/usr/local/lib/python3.7/dist-packages/selenium/webdriver/remote/errorhandler.py", line 242, in check_response raise exception_class(message, screen, stacktrace) selenium.common.exceptions.WebDriverException: Message: unknown error: Chrome failed to start: exited abnormally (unknown error: DevToolsActivePort file doesn't exist) (The process started from chrome location /usr/bin/chromium-browser is no longer running, so ChromeDriver is assuming that Chrome has crashed.) (Driver info: chromedriver=78.0.3904.108 (4b26898a39ee037623a72fcfb77279fce0e7d648-refs/branch-heads/3904@{#889}),platform=Linux 5.4.51-v7l+ armv7l)

leoncvlt commented 4 years ago

I don't have a Pi that I can test on, but from some googling around it seems that a workaround for this issue is to add

chrome_options.add_argument('--no-sandbox')
chrome_options.add_argument('--disable-dev-shm-usage')

to the chromedriver options. Can you test whether this fixes it?

sasagr commented 4 years ago

I added in scraper.py those lines: if headless: chrome_options.add_argument("--headless") chrome_options.add_argument("window-size=1920,1080") chrome_options.add_argument("--log-level=3") chrome_options.add_argument("--silent") chrome_options.add_argument("--disable-logging")

allows selenium to accept cookies with a non-int64 'expiry' value

chrome_options.add_experimental_option("w3c", False)
# removes the 'DevTools listening' log message
chrome_options.add_experimental_option("excludeSwitches", ["enable-logging"])
chrome_options.add_argument('--no-sandbox')
chrome_options.add_argument('--disable-dev-shm-usage')

and I still get the same error pi@raspberrypi:~/blinkist-scraper $ python3 blinkistscraper user pass --book https://www.blinkist.co m/en/nc/reader/on-saudi-arabia-en --chromedriver /usr/bin/chromedriver [14:55:51] INFO Starting scrape run... [14:55:51] INFO Initialising chromedriver at /usr/bin/chromedriver... Traceback (most recent call last): File "/usr/lib/python3.7/runpy.py", line 193, in _run_module_as_main "main", mod_spec) File "/usr/lib/python3.7/runpy.py", line 85, in _run_code exec(code, run_globals) File "blinkistscraper/main.py", line 340, in main() File "blinkistscraper/main.py", line 279, in main chromedriver_path=args.chromedriver, File "blinkistscraper/scraper.py", line 83, in initialize_driver options=chrome_options, File "/home/pi/.local/lib/python3.7/site-packages/seleniumwire/webdriver/browser.py", line 86, in init super().init(*args, **kwargs) File "/usr/local/lib/python3.7/dist-packages/selenium/webdriver/chrome/webdriver.py", line 81, in init desired_capabilities=desired_capabilities) File "/usr/local/lib/python3.7/dist-packages/selenium/webdriver/remote/webdriver.py", line 157, in init self.start_session(capabilities, browser_profile) File "/usr/local/lib/python3.7/dist-packages/selenium/webdriver/remote/webdriver.py", line 252, in start_session response = self.execute(Command.NEW_SESSION, parameters) File "/usr/local/lib/python3.7/dist-packages/selenium/webdriver/remote/webdriver.py", line 321, in execute self.error_handler.check_response(response) File "/usr/local/lib/python3.7/dist-packages/selenium/webdriver/remote/errorhandler.py", line 242, in check_response raise exception_class(message, screen, stacktrace) selenium.common.exceptions.WebDriverException: Message: unknown error: Chrome failed to start: exited abnormally (unknown error: DevToolsActivePort file doesn't exist) (The process started from chrome location /usr/bin/chromium-browser is no longer running, so ChromeDriver is assuming that Chrome has crashed.) (Driver info: chromedriver=78.0.3904.108 (4b26898a39ee037623a72fcfb77279fce0e7d648-refs/branch-heads/3904@{#889}),platform=Linux 5.4.51-v7l+ armv7l)

pi@raspberrypi:~/blinkist-scraper $

I will also post the full installation output in case you see something there:

pi@raspberrypi:~/blinkist-scraper $ pip3 install -r requirements.txt Defaulting to user installation because normal site-packages is not writeable Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple Collecting certifi==2020.6.20 Using cached certifi-2020.6.20-py2.py3-none-any.whl (156 kB) Requirement already satisfied: chardet==3.0.4 in /usr/lib/python3/dist-packages (from -r requirements.txt (line 4)) (3.0.4) Collecting chromedriver-autoinstaller==0.2.2 Downloading chromedriver_autoinstaller-0.2.2-py3-none-any.whl (5.9 kB) Collecting colorama==0.4.3 Downloading colorama-0.4.3-py2.py3-none-any.whl (15 kB) Collecting ebooklib==0.17.1 Downloading EbookLib-0.17.1.tar.gz (111 kB) |################################| 111 kB 565 kB/s Collecting idna==2.10 Using cached idna-2.10-py2.py3-none-any.whl (58 kB) Collecting lxml==4.5.2 Downloading lxml-4.5.2.tar.gz (4.5 MB) |################################| 4.5 MB 3.7 kB/s Collecting requests==2.24.0 Using cached requests-2.24.0-py2.py3-none-any.whl (61 kB) Requirement already satisfied: selenium==3.141.0 in /usr/local/lib/python3.7/dist-packages (from -r requirements.txt (line 53)) (3.141.0) Collecting selenium-wire==2.1.0 Downloading selenium_wire-2.1.0-py3-none-any.whl (833 kB) |################################| 833 kB 4.0 kB/s Collecting six==1.15.0 Using cached six-1.15.0-py2.py3-none-any.whl (10 kB) Collecting urllib3==1.25.10 Downloading urllib3-1.25.10-py2.py3-none-any.whl (127 kB) |################################| 127 kB 1.5 MB/s Building wheels for collected packages: ebooklib, lxml Building wheel for ebooklib (setup.py) ... done Created wheel for ebooklib: filename=EbookLib-0.17.1-py3-none-any.whl size=38162 sha256=eb06f1fe78f281a3867ac95cf863a5e4540b3bf6e80c6e0ded33e4977756444a Stored in directory: /home/pi/.cache/pip/wheels/43/39/fd/db4f652431a55d28472ba7f5f7c9a8efad03b97f443a48ea2f Building wheel for lxml (setup.py) ... done Created wheel for lxml: filename=lxml-4.5.2-cp37-cp37m-linux_armv7l.whl size=5985347 sha256=c66c60060feec06e2dc7d1420a4528871029de308faa09b5bd01dcd9e3021934 Stored in directory: /home/pi/.cache/pip/wheels/7d/1a/4f/3eb3b7476be59dd64ef26a07c5071955fd860bd51e4f69f02e Successfully built ebooklib lxml Installing collected packages: certifi, chromedriver-autoinstaller, colorama, lxml, six, ebooklib, idna, urllib3, requests, selenium-wire Attempting uninstall: certifi Found existing installation: certifi 2019.9.11 Uninstalling certifi-2019.9.11: Successfully uninstalled certifi-2019.9.11 Attempting uninstall: idna Found existing installation: idna 2.8 Uninstalling idna-2.8: Successfully uninstalled idna-2.8 Attempting uninstall: urllib3 Found existing installation: urllib3 1.25.6 Uninstalling urllib3-1.25.6: Successfully uninstalled urllib3-1.25.6 Attempting uninstall: requests Found existing installation: requests 2.22.0 Uninstalling requests-2.22.0: Successfully uninstalled requests-2.22.0 ERROR: After October 2020 you may experience errors when installing or updating packages. This is because pip will change the way that it resolves dependency conflicts.

We recommend you use --use-feature=2020-resolver to test your packages with the new resolver before it becomes the default.

astroid 2.3.2 requires six==1.12, but you'll have six 1.15.0 which is incompatible. docker-compose 1.26.2 requires python-dotenv<1,>=0.13.0, but you'll have python-dotenv 0.10.3 which is incompatible. Successfully installed certifi-2020.6.20 chromedriver-autoinstaller-0.2.2 colorama-0.4.3 ebooklib-0.17.1 idna-2.10 lxml-4.5.2 requests-2.24.0 selenium-wire-2.1.0 six-1.15.0 urllib3-1.25.10 WARNING: You are using pip version 20.2.2; however, version 20.2.3 is available. You should consider upgrading via the '/usr/bin/python3 -m pip install --upgrade pip' command. pi@raspberrypi:~/blinkist-scraper $

Pls advise if any other idea. thanks

rocketinventor commented 3 years ago

Hi @sasagr! Any updates on this?

sasagr commented 3 years ago

Not at all. After my last post I gave up and I m only using it on chrome on my Mac

johndoe-dev00 commented 3 years ago

Hi @sasagr, I had a similar problem when using pip on Windows/Linux. It seems to only work out of the box using poetry instead of pip. My workaround for pip was changing the requirements.txt by removing the version requirements like this:

chardet
chromedriver-autoinstaller
colorama
ebooklib
idna
lxml
requests
selenium
selenium-wire
six
urllib3

This seems to be related to pull request #37

leoncvlt commented 3 years ago

Think this got automatically closed by merging that other pull request, let me know if still appears to be an issue