Get hands-on experience with 20+ free Google Cloud products and $300 in free credit for new customers.

Using Playwright in cloud function (python)

Hi,

 I am new to cloud functions and writing a python function which uses Playwright (https://playwright.dev/python/docs/intro)

 As part of installation process, we need to install required browsers, how can I achieve this step?

 

I do see following messages in logs but I am not sure how to proceed

 

2022-11-21 08:30:51.300 IST╔═════════════════════════════════════╗
 
2022-11-21 08:30:51.300 IST║ Looks like Playwright was just installed or updated. ║
 
2022-11-21 08:30:51.300 IST║ Please run the following command to download new browsers: ║
 
2022-11-21 08:30:51.300 IST║ ║
 
2022-11-21 08:30:51.300 IST║ playwright install ║
 
2022-11-21 08:30:51.300 IST║ ║
 
2022-11-21 08:30:51.300 IST❤️ Playwright Team ║
 
2022-11-21 08:30:51.300 IST╚═════════════════════════════════════╝
 
This is the problem reported by someone https://github.com/microsoft/playwright-python/issues/1491
0 3 3,567
3 REPLIES 3

Hi @amit0,

You can use a Docker container to install a required browser just like chromium. 

using apt-get install chromium.

or you may change the default of the Playwright browser ex. Google Chrome, Microsoft Edge, etc.

browser = playwright.chromium.launch(channel="chrome")

Reference: https://playwright.dev/python/docs/browsers#chromium

For further help you can contact Google Cloud Support.

Thanks.

Hi Christian,

Trust you are doing good. I am stuck with the same problem. I tried running the following without a docker got an error, is docker the only solution, If I want to ensure these dependencies are pre installed in the environment ?

browser = p.chromium.launch(channel="chrome")

error:

playwright._impl._api_types.Error: Chromium distribution 'chrome' is not found at /opt/google/chrome/chrome
Run "playwright install chrome"

Please do guide me.

 Thanks

Hi @amit0 

Did you find a working solution to the problem, can you please help

Regards,

Anurag