I’ve had no problem using Playwright on Streamlit locally. But when I try to deploy the app using Github (and installed all dependencies via requirements.txt), it doesn’t seem to work because Playwright requires the additional “playwright install” command via the terminal to install browser binaries.
I get the following error:
2022-09-22 06:10:47.874 Uncaught app exception
Traceback (most recent call last):
File "/home/appuser/venv/lib/python3.9/site-packages/streamlit/runtime/scriptrunner/script_runner.py", line 556, in _run_script
exec(code, module.__dict__)
File "/app/feedings/main_pw.py", line 14, in <module>
browser = p.chromium.launch()
File "/home/appuser/venv/lib/python3.9/site-packages/playwright/sync_api/_generated.py", line 11678, in launch
self._sync(
File "/home/appuser/venv/lib/python3.9/site-packages/playwright/_impl/_sync_base.py", line 104, in _sync
return task.result()
File "/home/appuser/venv/lib/python3.9/site-packages/playwright/_impl/_browser_type.py", line 93, in launch
Browser, from_channel(await self._channel.send("launch", params))
File "/home/appuser/venv/lib/python3.9/site-packages/playwright/_impl/_connection.py", line 43, in send
return await self._connection.wrap_api_call(
File "/home/appuser/venv/lib/python3.9/site-packages/playwright/_impl/_connection.py", line 387, in wrap_api_call
return await cb()
File "/home/appuser/venv/lib/python3.9/site-packages/playwright/_impl/_connection.py", line 78, in inner_send
result = next(iter(done)).result()
playwright._impl._api_types.Error: Executable doesn't exist at /home/appuser/.cache/ms-playwright/chromium-1024/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 ║
╚════════════════════════════════════════════════════════════╝
Hello , To resolve this, you’ll need to ensure that all required packages are included in your packages.txt file , Include a packages.txt file: Streamlit Cloud also allows you to specify system-level packages that need to be installed. Playwright requires some additional packages to be installed on the system level. Create a packages.txt file in the root of your project with the following content:
After following the advice here I was still having problems, with errors in the terminal saying that dependencies weren’t being met - yet when I tried adding those dependencies to packages.txt, they couldn’t be found.
Long story short, Streamlit Community Cloud seems to be running on a version of Debian which doesn’t have access to the libraries that the latest Playwright (1.57.0, at this time) wants. Pinning Playwright to an earlier version got things working. I pinned to playwright==1.49.0