Reputation: 179
I've built a small fastapi app that scrapes some data from various sites and returnes it. whan I'm running it locally it works well, but when I try to run it as a Docker image the build fails with the error:
#8 3.356 ERROR: Could not find a version that satisfies the requirement playwright==1.27.1 (from versions: none)
#8 3.357 ERROR: No matching distribution found for playwright==1.27.1
this is my Dockerimage:
FROM python:3.9-alpine
COPY ../../requirements/dev.txt ./
RUN python3 -m ensurepip
RUN pip install -r dev.txt
ENV PYTHONPATH "${PYTHONPATH}:/app/"
WORKDIR /code/src
COPY ./src /app
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000", "--reload"]
and this is the 'requirements/dev.txt' file:
fastapi>=0.85.0
uvicorn>=0.18.3
mangum==0.10.0
playwright==1.27.1
Thanks.
Upvotes: 0
Views: 1874
Reputation: 12002
The issue is the docker image you have selected (alpine) architecture tags dont match any that playwright supports.
python:3.9:alpine
/code/src # pip debug --verbose | grep "py3-"
WARNING: This command is only meant for debugging. Do not use this with automation for parsing and getting these details, since the output and options of this command may change without notice.
py3-none-musllinux_1_2_x86_64
py3-none-musllinux_1_1_x86_64
py3-none-musllinux_1_0_x86_64
py3-none-linux_x86_64
py3-none-any
playwright tags
/code/src # pip install playwright -vv | grep "Skipping link" | cut -f2 -d'(' | cut -f1 -d')' | grep "^py3" | sort -u
ERROR: Could not find a version that satisfies the requirement playwright (from versions: none)
ERROR: No matching distribution found for playwright
py3-none-macosx_10_13_x86_64
py3-none-macosx_11_0_arm64
py3-none-macosx_11_0_universal2
py3-none-manylinux1_x86_64
py3-none-manylinux2014_aarch64, py3-none-manylinux_2_17_aarch64
py3-none-manylinux_2_27_x86_64
py3-none-win32
py3-none-win_amd64
This is why pip is telling you there is no matching distribution because its checking all the builds for playwright against the builds alpine linux wants and there isnt a common one, so it cannot install. You will need to use a docker image with an architecture that playwright is built against and supports. You can see this in more detail if you run pip install playwright -vv
in the alpine linux image
Skipping link: none of the wheel's tags (py3-none-manylinux2014_aarch64, py3-none-manylinux_2_17_aarch64) are compatible (run pip debug --verbose to show compatible tags): https://files.pythonhosted.org/packages/a6/c5/142449e50253fef
ff667584793ef303c1bb1ecf1cb849cd8b83cd9a653c1/playwright-1.27.1-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (from https://pypi.org/simple/playwright/) (requires-python:>=3.7)
Skipping link: none of the wheel's tags (py3-none-win32) are compatible (run pip debug --verbose to show compatible tags): https://files.pythonhosted.org/packages/79/54/cc0b824dd92507f4ed48e2a71424af2d0b4f91d72f3932ad4fefa7c68981/pla
ywright-1.27.1-py3-none-win32.whl (from https://pypi.org/simple/playwright/) (requires-python:>=3.7)
Skipping link: none of the wheel's tags (py3-none-win_amd64) are compatible (run pip debug --verbose to show compatible tags): https://files.pythonhosted.org/packages/5d/a0/e7009f47b7fef143617a2907fad14170a5ae765fe7bad8050402addd3cab
/playwright-1.27.1-py3-none-win_amd64.whl (from https://pypi.org/simple/playwright/) (requires-python:>=3.7)
Skipping link: not a file: https://pypi.org/simple/playwright/
Given no hashes to check 0 links for project 'playwright': discarding no candidates
ERROR: Could not find a version that satisfies the requirement playwright (from versions: none)
ERROR: No matching distribution found for playwright
You can see the architectures it builds against on there github https://github.com/microsoft/playwright-python/blob/release-1.27/setup.py#L79
Upvotes: 2