Why does it take ages to install Pandas on Alpine Linux

前端 未结 8 1386
孤独总比滥情好
孤独总比滥情好 2020-11-29 18:19

I\'ve noticed that installing Pandas and Numpy (it\'s dependency) in a Docker container using the base OS Alpine vs. CentOS or Debian takes much longer. I created a little t

8条回答
  •  攒了一身酷
    2020-11-29 18:54

    This worked for me:

    FROM python:3.8-alpine
    RUN echo "@testing http://dl-cdn.alpinelinux.org/alpine/edge/testing" >> /etc/apk/repositories
    RUN apk add --update --no-cache py3-numpy py3-pandas@testing
    ENV PYTHONPATH=/usr/lib/python3.8/site-packages
    
    COPY . /app
    WORKDIR /app
    
    RUN pip install -r requirements.txt
    
    EXPOSE 5003 
    ENTRYPOINT [ "python" ] 
    CMD [ "app.py" ]
    

    Most of the code here is from the answer of jtlz2 from this same thread and Faylixe from another thread.

    Turns out the lighter version of pandas is found in the Alpine repository py3-numpy but it doesn't get installed in the same file path from where Python reads the imports by default. Therefore you need to add the ENV. Also be mindful about the alpine version.

提交回复
热议问题