Playwright运行报错的解决
Published on 2023-06-12 14:03 in 暂未分类 with 写python的叮叮叮

Playwright运行报错的解决

    未安装浏览器报错

    playwright._impl._api_types.Error: Executable doesn't exist at /home/deploy/.cache/ms-playwright/firefox-1403/firefox/firefox
    ╔════════════════════════════════════════════════════════════╗
    ║ Looks like Playwright was just installed or updated.       ║
    ║ Please run the following command to download new browsers: ║
    ║                                                            ║
    ║     playwright install                                     ║
    ║                                                            ║
    ║ <3 Playwright Team                                         ║
    ╚════════════════════════════════════════════════════════════╝
    

    这个错误是因为没有安装playwright的浏览器导致的,需要输入以下命令安装浏览器

    playwright install
    ## 或者
    python -m playwright install
    
    ## 以上命令会安装所有浏览器,如果只需要安装一个浏览器比如firefox
    python -m playwright install firefox
    

    未安装依赖报错

    playwright._impl._api_types.Error: 
    ╔══════════════════════════════════════════════════════╗
    ║ Host system is missing dependencies to run browsers. ║
    ║ Missing libraries:                                   ║
    ║     libgtk-3.so.0                                    ║
    ║     libgdk-3.so.0                                    ║
    ║     libXcomposite.so.1                               ║
    ║     libXdamage.so.1                                  ║
    ║     libXfixes.so.3                                   ║
    ║     libXrandr.so.2                                   ║
    ║     libXtst.so.6                                     ║
    ║     libpangocairo-1.0.so.0                           ║
    ║     libpango-1.0.so.0                                ║
    ║     libatk-1.0.so.0                                  ║
    ║     libcairo-gobject.so.2                            ║
    ║     libcairo.so.2                                    ║
    ║     libgdk_pixbuf-2.0.so.0                           ║
    ║     libXcursor.so.1                                  ║
    ║     libXi.so.6                                       ║
    ╚══════════════════════════════════════════════════════╝
    

    这是因为没有安装playwright的依赖导致的问题,可以执行下面的命令来安装

    # centos
    yum -y install libappindicator-gtk3
    yum -y install liberation-fonts
    
    # ubuntu/debian
    apt-get install -y gstreamer1.0-libav libnss3-tools libatk-bridge2.0-0 libcups2-dev libxkbcommon-x11-0 libxcomposite-dev libxrandr2 libgbm-dev libgtk-3-0
    
    # ubuntu/debian也可以执行来安装依赖
    python -m playwright install --with-deps
    
    posted @   写python的叮叮叮  阅读(6825)  评论(0编辑  收藏  举报
    相关博文:
    阅读排行:
    · 使用C#创建一个MCP客户端
    · 分享一个免费、快速、无限量使用的满血 DeepSeek R1 模型,支持深度思考和联网搜索!
    · ollama系列1:轻松3步本地部署deepseek,普通电脑可用
    · 基于 Docker 搭建 FRP 内网穿透开源项目(很简单哒)
    · 按钮权限的设计及实现
    点击右上角即可分享
    微信分享提示