Код: Выделить всё
Message: session not created: Chrome failed to start: exited normally.
Код: Выделить всё
(The process started from chrome location /usr/bin/chromium is no longer running, so ChromeDriver is assuming that Chrome has crashed.)
Код: Выделить всё
FROM --platform=linux/amd64 python:3.9
ENV DEBIAN_FRONTEND noninteractive
RUN pip install --upgrade pip
# set environment variables
ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONUNBUFFERED 1
WORKDIR /app
COPY requirements.txt ./
RUN pip install -r requirements.txt --no-cache-dir
COPY . .
RUN apt update -y && apt install libgl1-mesa-glx sudo chromium chromium-driver -y
# Command to run the script
CMD ["python", "main.py"]
Код: Выделить всё
from selenium import webdriver
from selenium.webdriver.chrome.service import Service as ChromeService
from selenium.webdriver.common.by import By
from selenium.webdriver.chrome.options import Options
import time
chrome_options = Options()
chrome_options.add_argument("--no-sandbox")
chrome_options.add_argument("--headless") # Ensure GUI is off
chrome_options.add_argument("--disable-dev-shm-usage")
chrome_options.add_argument("--disable-gpu")
chrome_options.add_argument("--window-size=1920,1080")
chrome_options.add_argument("--remote-debugging-port=9222") # this
driver = webdriver.Chrome(options=chrome_options)
driver.get("https://www.google.com")
time.sleep(10)
print(driver.title)
driver.quit()
display.stop()
Подробнее здесь: https://stackoverflow.com/questions/786 ... le-silicon