Reputation: 51
I’m trying to setup a Docker image running python 2.7. The code I want to run within the container relies on packages I’m trying to get using pip during the Docker image built. My problem is that pip only gets some part of the packages issuing an error while trying to get the others. Here is my Docker file:
# Use an official Python runtime as a parent image
FROM python:2.7-slim
# Set the working directory to /app
WORKDIR /app
# Copy the current directory contents into the container at /app
ADD . /app
# Install any needed packages specified in requirements.txt
RUN pip install --trusted-host pypi.python.org -r requirements.txt
# Make port 80 available to the world outside this container
EXPOSE 80
# Define environment variable
ENV NAME World
# Run app.py when the container launches
CMD ["python", "./my_script.py"]
An here the requiremnts.txt
Flask
redis
time
sys
opcua
Pip has no problem with collecting Flask and redis, but issues error when it comes to collect time (the same problem with sys and opcua)
what should I do to make it work with all pip packages? Thanks in advance!
Upvotes: 4
Views: 5216
Reputation: 809
The issue here is time is a part of Python's standard library, so it's installed with the rest of Python. This means you do not (and cannot) pip install it. This goes for sys as well. Take these out of your requirements.txt
and you should be good to go!
Upvotes: 5