Hi,
I have issue with installing deps for playwright on hf spaces.
ERROR:
╔══════════════════════════════════════════════════════╗
║ Host system is missing dependencies to run browsers. ║
║ Please install them with the following command: ║
║ ║
║ sudo playwright install-deps ║
║ ║
║ Alternatively, use apt: ║
║ sudo apt-get install libnss3\ ║
║ libnspr4\ ║
║ libatk1.0-0\ ║
║ libatk-bridge2.0-0\ ║
║ libcups2\ ║
║ libatspi2.0-0\ ║
║ libxcomposite1\ ║
║ libxdamage1 ║
║ ║
║ <3 Playwright Team ║
╚══════════════════════════════════════════════════════╝
My Dockerfile:
FROM python:3.8
# Install necessary dependencies
RUN apt-get update && apt-get install -y \
libnss3 \
libnspr4 \
libatk1.0-0 \
libatk-bridge2.0-0 \
libcups2 \
libatspi2.0-0 \
libxcomposite1 \
libxdamage1 \
libxrandr2 \
libgbm-dev \
libgtk-3-0 \
xdg-utils \
&& rm -rf /var/lib/apt/lists/*
# Install Playwright and other dependencies
RUN pip install --upgrade pip
COPY requirements.txt .
RUN pip install -r requirements.txt
RUN playwright install --with-deps
# Utwórz użytkownika i ustaw katalog roboczy
RUN useradd -m -u 1000 user
USER user
WORKDIR /code
# Skopiuj plik requirements.txt i zainstaluj zależności Pythona
COPY --chown=user:user requirements.txt /code/requirements.txt
RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt
# Skopiuj resztę aplikacji
COPY --chown=user:user . /code
# Ustawienie punktu wejścia dla aplikacji
CMD ["python", "app.py"]
I try also this in code:
# Initialize Playwright
os.system("playwright install")
import subprocess
def install_playwright_and_deps():
try:
# Instalacja Playwright
subprocess.check_call(["pip", "install", "playwright"])
# Instalacja przeglądarek Playwright
subprocess.check_call(["apt-get", "playwright", "install-deps"])
except subprocess.CalledProcessError as e:
print(f"Error installing Playwright or dependencies: {e}")
install_playwright_and_deps()
Nothing help only I get a message about:
t validateDependenciesLinux (/usr/local/lib/python3.10/site-packages/playwright/driver/package/lib/server/registry/dependencies.js:216:9)
at async Registry._validateHostRequirements (/usr/local/lib/python3.10/site-packages/playwright/driver/package/lib/server/registry/index.js:575:43)
at async Registry._validateHostRequirementsForExecutableIfNeeded (/usr/local/lib/python3.10/site-packages/playwright/driver/package/lib/server/registry/index.js:673:7)
at async Registry.validateHostRequirementsForExecutablesIfNeeded (/usr/local/lib/python3.10/site-packages/playwright/driver/package/lib/server/registry/index.js:662:43)
at async t. (/usr/local/lib/python3.10/site-packages/playwright/driver/package/lib/cli/program.js:119:7)
Requirement already satisfied: playwright in /usr/local/lib/python3.10/site-packages (1.45.1)
Requirement already satisfied: greenlet==3.0.3 in /usr/local/lib/python3.10/site-packages (from playwright) (3.0.3)
Requirement already satisfied: pyee==11.1.0 in /usr/local/lib/python3.10/site-packages (from playwright) (11.1.0)
Requirement already satisfied: typing-extensions in /usr/local/lib/python3.10/site-packages (from pyee==11.1.0->playwright) (4.12.2)
[notice] A new release of pip available: 22.3.1 → 24.2
[notice] To update, run: pip install --upgrade pip
E: Invalid operation playwright
Error installing Playwright or dependencies: Command ‘[‘apt-get’, ‘playwright’, ‘install-deps’]’ returned non-zero exit status 100.
Running on local URL: http://0.0.0.0:7860
I dont have any other idea…
ChatGPT also didnt help much more than this
Maybe someone had more exp. with spaces and see an obviouse error that I made here