Skip to content
This repository was archived by the owner on Sep 11, 2025. It is now read-only.
This repository was archived by the owner on Sep 11, 2025. It is now read-only.

Playwright fails to launch Chromium on Heroku despite executable being present #26

@justinsane

Description

@justinsane

Description

I'm facing an issue while deploying a Python app on Heroku that utilizes Playwright to launch Chromium. Despite following best practices and ensuring the Chromium executable is present in the expected directory, I consistently receive an error stating that the "executable doesn't exist".

Env Details
Platform: Heroku
Buildpacks (in order):
mxschmitt/heroku-playwright-buildpack
heroku/python
Python V: 3.11
Playwright V: 1.36.0
Heroku Stack: heroku-22
Relevant Code:

with sync_playwright() as p:
  # Troubleshooting for local and Heroku build
  default_path = "/app/.heroku/python/lib/python3.11/site-packages/playwright/driver/package/.local-browsers/chromium-1071/chrome-linux/chrome"
  chromium_path = os.getenv("PLAYWRIGHT_CHROMIUM_PATH", default_path)

  browser = p.chromium.launch(
    headless=True, # Set False for debugging and local dev
    args=['--no-sandbox'],
    executable_path=chromium_path
      )
   # ... rest of code

Error Message
playwright._impl._api_types.Error: Failed to launch chromium because executable doesn't exist at /app/.heroku/python/lib/python3.11/site-packages/playwright/driver/package/.local-browsers/chromium-1071/chrome-linux/chrome

However, running heroku run bash and verify presence of the executable using ls, I can clearly see the Chromium executable present at the mentioned path.

Steps Taken:

Verified the presence of the Chromium executable on the Heroku Dyno.

Ensured the Playwright buildpack is correctly set up and is first in the order.

Tried using different environment variables including PLAYWRIGHT_BROWSERS_PATH and PLAYWRIGHT_CHROMIUM_PATH.

Checked for any potential conflicts with Selenium (previously used in the project) and its associated environment variables.

Expected
Playwright should successfully launch Chromium without any errors.

Actual
Playwright consistently fails to launch Chromium with an error stating the executable doesn't exist, even though it's present in the directory.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions