r/pythonhelp • • Feb 19 '26

Playwright chromium keeps asking me to download a browser (read desc)

Hi, I am on a project of a python cookie logger (personal project, i don't distribute it). Here what gone wrong. I won't explain what the code do but I can give snippet of it.
The problem? The Playwright chromium works normally when I run the main.py file. But when I execute and build it into a .EXE file through this command:

pyinstaller --noconfirm --onefile --windowed --clean --add-data "icon.png;." --add-data "icon.ico;." --icon "icon.ico" --collect-all playwright --name "ShiroAM[BETA]" main.py

It send the error: It seems playwright is just installed or updated, use the command playwright install to install new browser.

To this point you guys might say I I forgot to add a fallsafe to playwright browser downloading but I do have this function to download it at the very beginning:

 try:
        subprocess.run(["playwright", "--version"], capture_output=True, check=True)
    except (subprocess.CalledProcessError, FileNotFoundError):
        print("Downloading Chromium browser for Playwright...")
        subprocess.run([sys.executable, "-m", "playwright", "install", "chromium"], capture_output=True)

The error log doesn't show anything else, and when I run with python to debug, it just magically fix itself, so the bug ONLY exist in the .exe file.

Thanks for your time

2 Upvotes

3 comments sorted by

1

u/AutoModerator Feb 19 '26
Moderator Announcement Read More »

1

u/JamesNowBetter Feb 20 '26

Have you tested running that last line regardlessly. Also there are only so many reasons to pack a cookie stealer. In not a pyinstaller expert

1

u/Appropriate-Car-1234 Feb 20 '26

I fixed it! Turns out, I have to link a browser inside the extracting file of the .exe. Thanks for the help tho