You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

执行poetry add playwright遇AssertionError,求解决(MacOS Monterey)

解决Poetry安装Playwright时的AssertionError问题

以下是针对MacOS Monterey环境下,执行poetry add playwright触发AssertionError的解决步骤:

  • 升级Poetry到最新版本
    这个错误大概率是Poetry依赖解析器(mixology)的已知bug,升级到最新稳定版可修复:

    curl -sSL https://install.python-poetry.org | python3 -
    

    若你通过Homebrew安装Poetry,也可执行:

    brew upgrade poetry
    
  • 手动指定Playwright版本
    自动选择的^1.24.1可能和项目现有依赖存在冲突,尝试指定一个更兼容的稳定版本:

    poetry add playwright==1.30.0
    

    可根据项目Python版本调整合适的Playwright版本(比如Python3.9可兼容1.28+版本)

  • 清除Poetry缓存后重新解析
    缓存的依赖数据可能导致解析异常,清除后重试:

    poetry cache clear --all pypi
    poetry add playwright
    
  • 检查项目依赖冲突
    打开pyproject.toml,查看现有依赖是否存在版本限制过严的包,比如某些包指定了过窄的Python版本或依赖版本范围,导致Playwright无法兼容。可尝试放宽部分依赖的版本限制后重新执行安装命令。

  • 应急方案:用Pip安装后同步到Poetry
    若以上方法都无法快速解决,可临时用Pip安装后让Poetry同步锁文件:

    pip install playwright
    poetry add --lock playwright
    

内容的提问来源于stack exchange,提问作者CodeJedi

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.22 11:15:31