4

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)

Docker-machine output during build process

what should I do to make it work with all pip packages? Thanks in advance!

mustaccio
  • 18,234
  • 16
  • 48
  • 57
ArtJung
  • 51
  • 1
  • 3
  • 1) please type out the error message in the text body of your question to make it easier for us to look it up 2) have you tried explicitly installing specific versions? maybe look up the version that you want and replace `package==version` – R Balasubramanian Jul 11 '18 at 14:11
  • You need first confirm all things ok in host before blame the issue was related to container. – atline Jul 11 '18 at 14:17

1 Answers1

5

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!