Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ModuleNotFoundError: No module named 'playwright' during Firebase function deployment #8121

Open
chenei opened this issue Jan 17, 2025 · 1 comment

Comments

@chenei
Copy link

chenei commented Jan 17, 2025

[REQUIRED] Environment info

firebase-tools: 13.29.1

Platform: macOS

[REQUIRED] Test case

A minimal example where playwright module is imported in the scraper_with_pw.py file.

from playwright.async_api import async_playwright, Browser, Page

# Example function that uses Playwright
async def fetch_page():
    async with async_playwright() as p:
        browser = await p.chromium.launch()
        page = await browser.new_page()
        await page.goto('https://example.com')
        content = await page.content()
        await browser.close()
    return content

[REQUIRED] Steps to reproduce

  1. Install dependencies using pip install -r requirements.txt which includes playwright.
  2. Run the Flask app locally using firebase emulators:start --only functions.
  3. Deploy the Firebase function using firebase deploy --only functions.
  4. The error occurs when the function is triggered: ModuleNotFoundError: No module named 'playwright'.

[REQUIRED] Expected behavior

The playwright module should be successfully imported and used in the Firebase function, and the function should execute without errors.

[REQUIRED] Actual behavior

When running locally, everything works fine. However, when deploying the Firebase function, it fails with the following error:

ModuleNotFoundError: No module named 'playwright'

Additionally, the function deployment fails with the error:
`Failed to load function definition from source: FirebaseError: Functions codebase could not be analyzed successfully. It may have a syntax or runtime

@aalej
Copy link
Contributor

aalej commented Jan 21, 2025

Thanks for creating a detailed report, @chenei! I’m working on reproducing this, but so far no errors are being raised when invoking the function or deployments. I created this mcve to try and replicate the setup you have. Could you let me know if I may be missing anything here?

Also, just to verify, does the ModuleNotFoundError: No module named 'playwright' occur when triggering the function or during deployment?

@aalej aalej added the Needs: Author Feedback Issues awaiting author feedback label Jan 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants