Forums

Playwright chromium install failed.

I'm trying to install playwright using

python -m pip install playwright

which yielded success, but when I try to install the browser binary with

python -m playwright install

but I got the following:

Downloading Playwright build of chromium v907428 - 126 Mb [====================] 100% 0.0s 
Failed to install browsers
Error: Failed to download chromium v907428, caused by
Error: EIO: i/o error, write

I tried again for a few times and now the error changed to:

Removing unused browser at /home/hcaptcha/.cache/ms-playwright/chromium-907428
Downloading Playwright build of chromium v907428 - 126 Mb [====================] 100% 0.0s 
Failed to install browsers
Error: Failed to download chromium v907428, caused by
Error: ENOENT: no such file or directory, mkdir '/home/hcaptcha/.cache/ms-playwright/chromium- 
907428/chrome-linux/ClearKeyCdm/'.

I also tried install only chromium as one can do so per the documentation:

playwright install chromium

but got the same error. Any help? I'm using python 3.9.5 virtual env.

I don't think playwright will work on PythonAnywhere. We have a help page about using selenium here

I found a workaround for this, turns out pythonanywhere comes with a chromium binary preinstalled.

could you please explain how did you find this workaround?

pythonanywhere has a chromium binary preinstalled at /usr/bin/chromium.

So could you please give me the steps to make playwright work properly?

Set the executable path for the browser:

browser = playwright.chromium.launch(executable_path='/usr/bin/chromium')

Tips:

You can optionally disable GPU acceleration which I found give it better performance on a gpu-less runtime.

browser = playwright.chromium.launch(executable_path='/usr/bin/chromium', args=['--disable-gpu'])

Thanks, You saved my day

I still have this error though : net::ERR_TUNNEL_CONNECTION_FAILED at https://ent.ensa-tetouan.ac.ma/?home/index

I see you're trying to connect to a website via playwright. You have to ask the admin to whitelist the website. See https://help.pythonanywhere.com/pages/RequestingAllowlistAdditions

You will also find all the required chromium arguments here

when I try setting the executable path for the browser using
browser = playwright.chromium.launch(executable_path='/usr/bin/chromium')

I get the following error
bash: syntax error near unexpected token `('

It's been a while since the last post on this thread, but I'd like to add a sincere "thanks!" to @hcaptcha for the suggestion. We now have a help page for Playwright that includes their suggestion, and has some minimal code to help people get started.