Skip to content

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

Description

@rekcodocker

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:

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions