Home > Net >  Why get pip install error, when run docker build on only M1 mac
Why get pip install error, when run docker build on only M1 mac

Time:05-17

I'm using Intel and Apple Silicon chip Mac.

When I build dockerfile on Intel Mac, it is success. How ever when I build same file on M1 Mac I get This error.


#10 3.254 ERROR: Could not find a version that satisfies the requirement google-python-cloud-debugger (from versions: none)
#10 3.255 ERROR: No matching distribution found for google-python-cloud-debugger
------
executor failed running [/bin/sh -c python -m pip install --upgrade pip && pip install -r requirements.txt]: exit code: 1

This is not only google-python-cloud-debugger. If I remove it, another modules hits same error.

How to solve this problem?

My requirements.txt and dockerfile is below.

gunicorn==19.9.0
selenium==3.141.0
webdriver-manager==3.5.2
google-python-cloud-debugger
google-cloud-storage
django==3.2
mysqlclient==2.1.0
pysqlite3==0.4.6
django-storages==1.12.3
Pillow==9.0.0
requests==2.27.1
FROM python:3.9-buster

# Install manually all the missing libraries
RUN apt-get update && apt-get install -y gconf-service libasound2 libatk1.0-0 libcairo2 libcups2 libfontconfig1 libgdk-pixbuf2.0-0 libgtk-3-0 libnspr4 libpango-1.0-0 libxss1 fonts-liberation libappindicator1 libnss3 lsb-release xdg-utils wget fonts-takao-*

# Install Chrome
RUN wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
RUN dpkg -i google-chrome-stable_current_amd64.deb; apt-get -fy install

# Install Python dependencies.
COPY requirements.txt requirements.txt
RUN python -m pip install --upgrade pip && pip install -r requirements.txt

# Copy chrome driver
COPY drivers /root/.wdm/drivers

# Copy local code to the container image.
COPY . /app
ENV APP_HOME /app/website
WORKDIR $APP_HOME

# Run the web service on container startup. Here we use the gunicorn
CMD exec gunicorn --bind :$PORT --workers 1 --threads 8 website.wsgi

CodePudding user response:

I solved this problem! When we build dockerfile on M1 Mac, we need specify platform. So you need to add --platform=linux/x86_64 after FROM on dockerfile.

Example

FROM --platform=linux/x86_64 python:3.9-buster
  • Related