Mostafamabrok / satellitescraper

Easy to use python package for scraping high-resolution satellite images from apple maps.🌎
GNU General Public License v3.0
10 stars 0 forks source link

Error running in docker #20

Closed chiefMarlin closed 2 weeks ago

chiefMarlin commented 2 weeks ago

Hey, Im trying to get it running in a docker container (amd64) however i am getting below error. This is my Dockerfile

FROM python:3.10
RUN apt-get update && apt-get install -y chromium chromium-driver git
RUN pip install satellitescraper
WORKDIR /scraper
RUN git clone https://github.com/Mostafamabrok/satellitescraper.git
# Install requirements
RUN pip install -r satellitescraper/requirements.txt
# RUN cp -r satellitescraper/satellitescraper /usr/local/lib/python3.8/site-packages/
COPY scrape.py /scraper/scrape.py

And this is the error i am seeing when running python3 /scraper/satellitescraper test.py

Traceback (most recent call last):
  File "/scraper/satellitescraper/test.py", line 4, in <module>
    from satellitescraper.map_fetch import *
  File "/scraper/satellitescraper/satellitescraper/__init__.py", line 7, in <module>
    from .sanity_checker import sanity_check
  File "/scraper/satellitescraper/satellitescraper/sanity_checker.py", line 215, in <module>
    sanity_obj = map_api(min_lat_deg = 10,
  File "/scraper/satellitescraper/satellitescraper/satellitescraper.py", line 84, in __init__
    self._getAPIKey()
  File "/scraper/satellitescraper/satellitescraper/satellitescraper.py", line 189, in _getAPIKey
    driver = webdriver.Chrome(service=service, options=options)
  File "/usr/local/lib/python3.10/site-packages/selenium/webdriver/chrome/webdriver.py", line 45, in __init__
    super().__init__(
  File "/usr/local/lib/python3.10/site-packages/selenium/webdriver/chromium/webdriver.py", line 66, in __init__
    super().__init__(command_executor=executor, options=options)
  File "/usr/local/lib/python3.10/site-packages/selenium/webdriver/remote/webdriver.py", line 238, in __init__
    self.start_session(capabilities)
  File "/usr/local/lib/python3.10/site-packages/selenium/webdriver/remote/webdriver.py", line 325, in start_session
    response = self.execute(Command.NEW_SESSION, caps)["value"]
  File "/usr/local/lib/python3.10/site-packages/selenium/webdriver/remote/webdriver.py", line 380, in execute
    self.error_handler.check_response(response)
  File "/usr/local/lib/python3.10/site-packages/selenium/webdriver/remote/errorhandler.py", line 229, in check_response
    raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.SessionNotCreatedException: Message: session not created: Chrome failed to start: exited normally.
  (session not created: DevToolsActivePort file doesn't exist)
  (The process started from chrome location /usr/bin/chromium is no longer running, so ChromeDriver is assuming that Chrome has crashed.)
Stacktrace:
#0 0x55b39729513a <unknown>
#1 0x55b396db0460 <unknown>
#2 0x55b396de622a <unknown>
#3 0x55b396de1ca5 <unknown>
#4 0x55b396e2d156 <unknown>
#5 0x55b396e2c7a6 <unknown>
#6 0x55b396e20db3 <unknown>
#7 0x55b396defc10 <unknown>
#8 0x55b396df0bee <unknown>
#9 0x55b3972613cb <unknown>
#10 0x55b397265368 <unknown>
#11 0x55b39724eeec <unknown>
#12 0x55b397265ee7 <unknown>
#13 0x55b39723413f <unknown>
#14 0x55b397283858 <unknown>
#15 0x55b397283a20 <unknown>
#16 0x55b397293fb6 <unknown>
#17 0x7fbde7cd5144 <unknown>
Mostafamabrok commented 2 weeks ago

are you running on windows or linux?

Mostafamabrok commented 2 weeks ago

also, do you have chrome installed?? i believe that is a requirement. I also think i forgot to say it in any docs tho lol

chiefMarlin commented 2 weeks ago

Im running on linux, in the dockerfile i installed chromium chromium-driver

Mostafamabrok commented 2 weeks ago

hmmmm, try starting chrome, and then running it if that doesnt work we may have some bigger issues

chiefMarlin commented 2 weeks ago

Is there any way to force it to use chromium headless ? As this is a docker container there is no gui. Idea is to use chromium in headless mode

Mostafamabrok commented 2 weeks ago

selenium.common.exceptions.SessionNotCreatedException: Message: session not created: Chrome failed to start: exited normally. (session not created: DevToolsActivePort file doesn't exist) (The process started from chrome location /usr/bin/chromium is no longer running, so ChromeDriver is assuming that Chrome has crashed.)

so chrome is opening and exiting immedietly, i think at least.

let me see if there is a way to get selenium to open it headless

chiefMarlin commented 2 weeks ago

Thank you

Mostafamabrok commented 2 weeks ago

in the code, it already creates a headless instance

options.add_argument('headless')