2

I've been trying to get a docker file running for three days now, but keep failing to install pandas.

Here you can see my Dockerfile

# Dockerfile
# Use an official Python runtime as a parent image
FROM python:3.8-slim-buster

# Set the working directory to /app
# in the container
WORKDIR /app

# Install any needed packages specified in requirements.txt
COPY requirements.txt /app/requirements.txt
RUN pip install -r requirements.txt

# Copy the python script
COPY modbus_to_influx.py /app/modbus_to_influx.py

# Run app.py when the container launches
# The -u flag specifies to use the unbuffered output.
# in this way, what's printed by the app is visible on the host
# while the container is running
CMD ["python3", "-u", "modbus_to_influx.py"]

And here the requirements.txt

influxdb
minimalmodbus
numpy 
pandas

What am I doing wrong here?


I have the solution

I've used now not the python container, instead, I've used the Debian container and installed there all dependencies. This works fine now

# Dockerfile
# Use an official Python runtime as a parent image
FROM debian:10.3-slim

# Set the working directory to /app
# in the container
WORKDIR /app

# Install any needed packages specified in requirements.txt
RUN apt-get update && apt-get -y dist-upgrade

RUN apt-get -y install apt-utils \
    build-essential \
    python3 \
    gcc \
    python3-dev \
    python3-pip \
    python3-numpy \
    python3-pandas

COPY requirements.txt /app/requirements.txt
RUN pip3 install -r requirements.txt

# Copy the python script
COPY modbus_to_influx.py /app/modbus_to_influx.py

# Run app.py when the container launches
# The -u flag specifies to use the unbuffered ouput.
# in this way, what's printed by the app is visible on the host
# while the container is running
CMD ["python3", "-u", "modbus_to_influx.py"]
12
  • can you try running python3 -m pip install -r requiments.txt ? might be different versions of python Commented Apr 7, 2020 at 10:37
  • What error do you get with pandas installation? Commented Apr 7, 2020 at 10:39
  • @Ioanna:I do not get an "error message", the installing build dependencies just run forever Commented Apr 7, 2020 at 10:45
  • @Bernardostearnsreisen: I will try it Commented Apr 7, 2020 at 10:46
  • 1
    Does this answer your question? Install pandas in a Dockerfile Commented Apr 7, 2020 at 10:54

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.