在Docker中安装熊猫

时间:2020-04-07 10:34:30

标签: python pandas docker

我一直在尝试使docker文件运行三天,但一直无法安装熊猫。

在这里您可以看到我的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"]

这里是requirements.txt

influxdb
minimalmodbus
numpy 
pandas

我在做什么错了?


我有解决办法

我现在不使用python容器,而是使用Debian容器并在其中安装所有依赖项。现在可以正常使用

# 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"]

0 个答案:

没有答案