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

Browser executable not found when PLAYWRIGHT_BROWSERS_PATH is 0 #494

Closed
muffinmad opened this issue Feb 11, 2021 · 7 comments
Closed

Browser executable not found when PLAYWRIGHT_BROWSERS_PATH is 0 #494

muffinmad opened this issue Feb 11, 2021 · 7 comments

Comments

@muffinmad
Copy link

muffinmad commented Feb 11, 2021

Steps to reproduce:

  1. mkvirtualenv pyplaywright
  2. pip install playwright==1.8.0a1
  3. PLAYWRIGHT_BROWSERS_PATH=0 python -m playwright install chromium
chromium v844399 downloaded to /Users/mad/.virtualenvs/pyplaywright/lib/python3.7/site-packages/playwright/driver/package/.local-browsers/chromium-844399
  1. PLAYWRIGHT_BROWSERS_PATH=0 python
>>> from playwright.sync_api import sync_playwright
>>> with sync_playwright() as p:
...     p.chromium.launch()
... 
playwright._impl._api_types.Error: Failed to launch chromium because executable doesn't exist at /Users/mad/.virtualenvs/html2pdf/lib/python3.7/site-packages/playwright/driver/package/lib/cli/.local-browsers/chromium-844399/chrome-mac/Chromium.app/Contents/MacOS/Chromium

The search path is differs from the installation path.

@mxschmitt
Copy link
Member

PLAYWRIGHT_BROWSERS_PATH is not supported for Python afaik. What are you trying to achieve?

The driver is in the Python module directory and the browsers are globally located: https://playwright.dev/docs/installation?_highlight=playwright_browsers_path#managing-browser-binaries maybe that helps you.

@pavelfeldman
Copy link
Member

It should work. I think we recently fixed it.

@dgozman
Copy link
Contributor

dgozman commented Feb 11, 2021

This was fixed in microsoft/playwright#5217.

@muffinmad
Copy link
Author

I was trying to do hermetic install and place binaries under the site-packages/playwright folder as noted in this installation instruction.

I'm unable to pip install git+https://github.com/microsoft/playwright-python, I'll wait the next release on pypi.

Thanks!

@dgozman
Copy link
Contributor

dgozman commented Feb 12, 2021

I was trying to do hermetic install and place binaries under the site-packages/playwright folder as noted in this installation instruction.

You were doing the right thing, it was broken. Next v1.9 release (coming soon) will have it fixed. Thank you!

@ebzimny01
Copy link

It's not clear to me. Is this supposed to be resolved for Windows too? Or only Linux?

If I create a virtualenv in Linux and set the PLAYWRIGHT_BROWSERS_PATH=0, it will place the installed browser in the virtualenv:

  1. mkvirtualenv testenv

  2. pip install playwright

  3. PLAYWRIGHT_BROWSERS_PATH=0 python -m playwright install firefox
    /.virtualenvs/testenv/lib/python3.8/site-packages/playwright/driver/package/.local-browsers/firefox-1234

  4. PLAYWRIGHT_BROWSERS_PATH=0 python

  5. Then run the sample code above and it will find the firefox browser in the virtualenv correctly.

But when I attempt this in Win10, it always places the browser in the local user profile in the ms-playwright folder, never within the virtualenv:

  1. python -m venv testenv
  2. set PLAYWRIGHT_BROWSERS_PATH=0
  3. pip install playwright
  4. playwright install firefox
    firefox v1234 downloaded to C:\Users\user1\AppData\Local\ms-playwright\firefox-1234

Any thoughts?

@mxschmitt
Copy link
Member

mxschmitt commented Feb 3, 2023

You are inside PowerShell, if you are inside PowerShell you need to set environment variables by doing the following:

$Env:PLAYWRIGHT_BROWSERS_PATH=0

then it works for me.

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

5 participants