英文:
Playwright install-deps fails in Dockerfile
问题
我有一个小应用程序,使用playwright从各种网站抓取数据。
应用程序已经成功Docker化,并且一切正常,直到我尝试重新构建Docker镜像(代码实际上没有改变),但安装playwright依赖项失败了(与以前一样)。
这是Dockerfile:
FROM python:3.9-slim
COPY ../../requirements/dev.txt ./
RUN python3 -m ensurepip
RUN pip install -r dev.txt
RUN playwright install
RUN playwright install-deps
ENV PYTHONPATH "${PYTHONPATH}:/app/"
WORKDIR /code/src
EXPOSE 8000
COPY ./src /app
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000", "--reload"]
这是requirements:
fastapi>=0.85.0
uvicorn>=0.18.3
bs4==0.0.1
playwright
这是错误消息:
=> ERROR [6/8] RUN playwright install-deps
------
> [6/8] RUN playwright install-deps:
#10 0.762 BEWARE: your OS is not officially supported by Playwright; installing dependencies for Ubuntu as a fallback.
#10 0.762 Installing dependencies...
...
#10 3.975 Failed to install browser dependencies
#10 3.975 Error: Installation process exited with code: 100
------
executor failed running [/bin/sh -c playwright install-deps]: exit code: 1
我运行的命令是 'docker-compose build'。
希望有人能帮忙,谢谢。
英文:
I have a small application that uses playwright to scrape data from various websites.
The application is Dockerized well and everything worked perfectly until I tried to re-build the Docker image (nothing really changed in the code) and it failed to install the playwright deps (like it used to before).
This is the Dockerfile:
FROM python:3.9-slim
COPY ../../requirements/dev.txt ./
RUN python3 -m ensurepip
RUN pip install -r dev.txt
RUN playwright install
RUN playwright install-deps
ENV PYTHONPATH "${PYTHONPATH}:/app/"
WORKDIR /code/src
EXPOSE 8000
COPY ./src /app
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000", "--reload"]
This is the requirements:
fastapi>=0.85.0
uvicorn>=0.18.3
bs4==0.0.1
playwright
This is the error message:
=> ERROR [6/8] RUN playwright install-deps 4.1s
------
> [6/8] RUN playwright install-deps:
#10 0.762 BEWARE: your OS is not officially supported by Playwright; installing dependencies for Ubuntu as a fallback.
#10 0.762 Installing dependencies...
#10 1.084 Get:1 http://deb.debian.org/debian bookworm InRelease [147 kB]
#10 1.269 Get:2 http://deb.debian.org/debian bookworm-updates InRelease [52.1 kB]
#10 1.338 Get:3 http://deb.debian.org/debian-security bookworm-security InRelease [48.0 kB]
#10 1.407 Get:4 http://deb.debian.org/debian bookworm/main amd64 Packages [8904 kB]
#10 2.278 Get:5 http://deb.debian.org/debian-security bookworm-security/main amd64 Packages [24.2 kB]
#10 3.063 Fetched 9176 kB in 2s (4021 kB/s)
#10 3.063 Reading package lists...
#10 3.474 Reading package lists...
#10 3.868 Building dependency tree...
#10 3.969 Reading state information...
#10 3.972 Package ttf-ubuntu-font-family is not available, but is referred to by another package.
#10 3.972 This may mean that the package is missing, has been obsoleted, or
#10 3.972 is only available from another source
#10 3.972
#10 3.972 Package libjpeg-turbo8 is not available, but is referred to by another package.
#10 3.972 This may mean that the package is missing, has been obsoleted, or
#10 3.972 is only available from another source
#10 3.972
#10 3.972 Package ttf-unifont is not available, but is referred to by another package.
#10 3.972 This may mean that the package is missing, has been obsoleted, or
#10 3.972 is only available from another source
#10 3.972 However the following packages replace it:
#10 3.972 fonts-unifont
#10 3.972
#10 3.972 Package xfonts-cyrillic is not available, but is referred to by another package.
#10 3.972 This may mean that the package is missing, has been obsoleted, or
#10 3.972 is only available from another source
#10 3.972
#10 3.974 E: Package 'ttf-unifont' has no installation candidate
#10 3.974 E: Package 'xfonts-cyrillic' has no installation candidate
#10 3.974 E: Package 'ttf-ubuntu-font-family' has no installation candidate
#10 3.974 E: Unable to locate package libx264-155
#10 3.974 E: Unable to locate package libenchant1c2a
#10 3.974 E: Unable to locate package libicu66
#10 3.974 E: Package 'libjpeg-turbo8' has no installation candidate
#10 3.974 E: Unable to locate package libvpx6
#10 3.974 E: Unable to locate package libwebp6
#10 3.975 Failed to install browser dependencies
#10 3.975 Error: Installation process exited with code: 100
------
executor failed running [/bin/sh -c playwright install-deps]: exit code: 1
The command I'm running is 'docker-compose build'.
Hope someone could help, Thanks.
答案1
得分: 2
我将基础镜像更改为更新的版本,现在它正常工作。
而不是:
FROM python:3.9-slim```
<details>
<summary>英文:</summary>
Solution:
I changed the base image to a newer version and now it is working properly.
FROM python:3.10.7
instead of:
FROM python:3.9-slim
</details>
# 答案2
**得分**: 0
这是因为在2023年6月10日,debian发布了一个新版本["bookworm"](https://www.debian.org/News/2023/20230610),似乎破坏了playwright的集成,所以为了修复它,你可以将基础镜像更改为`bullseye`标签,`slim`始终使用最新的debian稳定版本。
```python:3.9-bullseye
英文:
This is happening because on June 10th, 2023 debian release a new version "bookworm" that seems that broke the playwright integration, so in order to fix you could change the base image to bullseye
tag, slim
always use the latest debian stable version.
python:3.9-bullseye
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论