Note: The Listed platform will permanently shut down December 31, 2026. Your data published on Listed will still be available in your personal Standard Notes account. Learn more

Python错误from playwright.sync_api import sync_playwright ModuleNotFoundError: No module named 'playwright'

Traceback (most recent call last): File "E:\baidu\baiwen.py", line 1, in from playwright.syncapi import syncplaywright ModuleNotFoundError: No module named 'playwright'

不是代码问题,是你环境没装 playwright

🧠 一、报错意思

ModuleNotFoundError: No module named 'playwright'

👉 就是:

❌ Python 找不到这个库


🚀 二、解决方法(一步到位)

✅ 1. 安装 playwright

在你的命令行(CMD / PowerShell)执行:

pip install playwright

✅ 2. 安装浏览器内核(必须做!!)

安装完还不够,还要:

playwright install

⚠️ 三、很多人卡在这里(重点)

只执行:

pip install playwright

❌ 是不够的

必须再执行:

playwright install

🧠 四、如果你在 Windows(你这个路径是 Windows)

建议用:

python -m playwright install

🚀 五、验证是否成功

运行:

from playwright.sync_api import sync_playwrightprint("ok")

没有报错 = 成功


You'll only receive email when they publish something new.

More from Daedalus🫧🪁🏒
All posts