Forums

Help installing playwright

Hello,

I'm trying to install Playwright and I'm really not very sure what I'm doing.

Per the docs: https://github.com/microsoft/playwright-python#evaluate-js-in-browser

One must perform 2 steps: pip install playwright python -m playwright install

I've pip installed playwright on my python3.8 virtual env but am unable to complete the second step. I've tried to cd into the directories that contain playwright prior to entering the "python -m playwright install" command but am getting the following:

(

my-virtualenv) 20:48 ~/.local/lib/python3.8/site-packages/playwright $ cd /home/nweather2/.local/lib/python3.8/site-packages/playwright
(my-virtualenv) 20:48 ~/.local/lib/python3.8/site-packages/playwright $ python -m playwright install
Traceback (most recent call last):
  File "/usr/lib/python3.8/runpy.py", line 192, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/usr/lib/python3.8/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/home/nweather2/.local/lib/python3.8/site-packages/playwright/playwright.py", line 17, in <module>
    from playwright.browser_type import BrowserType
  File "/home/nweather2/.local/lib/python3.8/site-packages/playwright/playwright.py", line 17, in <module>
    from playwright.browser_type import BrowserType
ModuleNotFoundError: No module named 'playwright.browser_type'; 'playwright' is not a package

Can anyone help?

Thanks.

How did you install that package? Installation in .local is not the installation in your virtual environment. Why did you change the directory?

Thanks for your response, I initially changed the directory because I couldn't get it to work without doing so - I was getting the same error, anyways, I razed that venv, made another and seem to be in good shape. Thanks.

14:06 /usr/bin $ mkvirtualenv cleanSlate --python=/usr/bin/python3.8
Running virtualenv with interpreter /usr/bin/python3.8
Already using interpreter /usr/bin/python3.8
Using base prefix '/usr'
New python executable in /home/nweather2/.virtualenvs/cleanSlate/bin/python3.8
Also creating executable in /home/nweather2/.virtualenvs/cleanSlate/bin/python
Installing setuptools, pip, wheel...
done.
virtualenvwrapper.user_scripts creating /home/nweather2/.virtualenvs/cleanSlate/bin/predeactivate
virtualenvwrapper.user_scripts creating /home/nweather2/.virtualenvs/cleanSlate/bin/postdeactivate
virtualenvwrapper.user_scripts creating /home/nweather2/.virtualenvs/cleanSlate/bin/preactivate
virtualenvwrapper.user_scripts creating /home/nweather2/.virtualenvs/cleanSlate/bin/postactivate
virtualenvwrapper.user_scripts creating /home/nweather2/.virtualenvs/cleanSlate/bin/get_env_details
(cleanSlate) 14:08 /usr/bin $ pip install playwright
Looking in links: /usr/share/pip-wheels
Collecting playwright
  Using cached playwright-0.162.1-py3-none-manylinux1_x86_64.whl (60.4 MB)
Collecting greenlet>=0.4.17
  Using cached greenlet-0.4.17-cp38-cp38-manylinux1_x86_64.whl (48 kB)
Collecting typing-extensions
  Using cached typing_extensions-3.7.4.3-py3-none-any.whl (22 kB)
Collecting pyee>=8.0.1
  Using cached pyee-8.1.0-py2.py3-none-any.whl (12 kB)
Installing collected packages: greenlet, typing-extensions, pyee, playwright
Successfully installed greenlet-0.4.17 playwright-0.162.1 pyee-8.1.0 typing-extensions-3.7.4.3
(cleanSlate) 14:08 /usr/bin $ python -m playwright install
Failed to process descriptor at /home/nweather2/.virtualenvs/my-virtualenv/lib/python3.8/site-packages/playwright/driver

Great!