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

[Bug]: mcr.microsoft.com/playwright/python does not work without 'pip install playwright' #34872

Open
rekcodocker opened this issue Feb 19, 2025 · 1 comment

Comments

@rekcodocker
Copy link

Version

mcr.microsoft.com/playwright/python:v1.50.0-noble

Steps to reproduce

  1. Start the container in interactive mode with the provided run command:

docker run -it --rm --ipc=host --user pwuser --security-opt seccomp=seccomp_profile.json mcr.microsoft.com/playwright/python:v1.50.0-noble /bin/bash

  1. start python: "python"

  2. type "from playwright.sync_api import sync_playwright"

Python throws an error:
Traceback (most recent call last):
File "", line 1, in
ModuleNotFoundError: No module named 'playwright'

  1. Exit python
  2. run 'pip install playwright'
  3. retry step 3, the import works and playwright works with python.

Conclusion: The container does not allow Python to use playwright out of the box, it is missing the playwright-python component.

Expected behavior

"ok" - the import works and I can start issuing playwright-calls.

I expect the playwright/python container to contain the necessary components to at least use Playwright from within python.
As it stands it is a playwright-container which happens to have Python installed, but as a separate component with no connection to Playwright.

Actual behavior

Python throws an error:
Traceback (most recent call last):
File "", line 1, in
ModuleNotFoundError: No module named 'playwright'

  1. Exit python
  2. run 'pip install playwright'
  3. retry step 3, the import works and playwright works with python.

Additional context

I could be be all wrong. Perhaps I am using the playwright/python container in the wrong way.

But:

  • the instructions for playwright + python (not the docker version) state that you must run at least "pip install pytest-playwright"
  • the instructions for the playwright/python container state that you can pull the image and run
    "from playwright.sync_api import sync_playwright" (it says so in https://playwright.dev/python/docs/docker )

Environment

- Operating System: [Ubuntu 22.04]
- CPU: [intel]
- Browser: [All, Chromium, Firefox, WebKit]
- Python Version: [3.12]
- Other info:
@mxschmitt
Copy link
Member

mxschmitt commented Feb 20, 2025

In none of Playwright's Docker containers we install Playwright, we install only the browsers and system dependencies as per here. Since usually there are multiple package-managers in the ecosystem we don't want to assume which one you are using. This applies to Python and Node.js as well.

Would installing it work for you? We could also add another note that its required to have Playwright installed via e.g. pip.

@mxschmitt mxschmitt transferred this issue from microsoft/playwright-python Feb 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants