Is there a way to run a script when building a Gradio space?

I have a Gradio space that needs the Playwright Python library. I have the library installed using the requirements file. However, I couldn’t figure out how to “playwright install” as required. The app through the follow error message without the additional step.

playwright._impl._api_types.Error: Executable doesn’t exist at /home/user/.cache/ms-playwright/chromium-1080/chrome-linux/chrome
║ Looks like Playwright was just installed or updated. ║
║ Please run the following command to download new browsers: ║
║ ║
║ playwright install ║
║ ║
║ <3 Playwright Team ║


hi @shulik7 ,

You can use this Gradio Docker SDK and run commands during build time

Another option

import subprocess["playwright", "install"])

@radames Thanks for the reply, and sorry for the very late response.

I no longer use the Huggingface space because my private space was accessed without authorization. I couldn’t determine the reason, but weeks later, I received an email from Huggingface stating that their team had detected unauthorized access to our Spaces platform, specifically related to Spaces secrets. As a result, they suspect that a subset of Spaces’ secrets might have been accessed without authorization.