网上建议
网上好多文章介绍playwright的环境搭建,用以下两条语句即可完成
pip install playwright
playwright install
安装完毕后,尝试执行一段经典的python demo
from playwright.sync_api import sync_playwright
with sync_playwright() as p:
browser = p.chromium.launch()
page = browser.new_page()
page.goto("http://www.baidu.com")
print(page.title())
browser.close()
很不幸,相信绝大多数同学会遇到下面的报错
Traceback (most recent call last):
File "C:/Users/Administrator/PycharmProjects/playwright/demo1.py", line 1, in <module>
from playwright.sync_api import sync_playwright
File "C:\Python37\lib\site-packages\playwright\sync_api\__init__.py", line 25, in <module>
import playwright.sync_api._generated
File "C:\Python37\lib\site-packages\playwright\sync_api\_generated.py", line 25, in <module>
from playwright._impl._accessibility import Accessibility as AccessibilityImpl
File "C:\Python37\lib\site-packages\playwright\_impl\_accessibility.py", line 17, in <module>
from playwright._impl._connection import Channel
File "C:\Python37\lib\site-packages\playwright\_impl\_connection.py", line 23, in <module>
from greenlet import greenlet
File "C:\Python37\lib\site-packages\greenlet\__init__.py", line 29, in <module>
from ._greenlet import _C_API # pylint:disable=no-name-in-module
ImportError: DLL load failed: 找不到指定的模块。
这个问题该如何解决呢?还需要安装模块msvc-runtime
pip install msvc-runtime
然后再次运行脚本,可以正常运行!
最靠谱的做法
执行三条语句
pip install playwright
playwright install
pip install msvc-runtime
标签:load,playwright,py,sync,报错,._,import,line From: https://blog.51cto.com/liwen629/7621137