skip to Main Content

i am creating image with below dockerfile:

FROM python:3.9
WORKDIR /usr/app/
ADD ./requirements.txt /usr/app/requirements.txt
RUN pip install --upgrade pip && 
 hash pip && 
 pip install -r requirements.txt
Add . /usr/app/
ENTRYPOINT ["python"]
CMD ["app.py"]

requirements file:

altair==4.1.0
cmdstanpy==1.0.8
h5py==3.1.0
keras-preprocessing==1.1.2
matplotlib==3.4.2
numpy
opt-einsum==3.3.0
pandas==1.2.4
params-flow
patsy==0.5.3
pmdarima==2.0.2
prophet==1.1.1
pydeck==0.6.2
scikit-learn==0.24.2
scipy==1.6.3
seaborn==0.11.1
statsmodels==0.13.5
streamlit==0.81.1
tensorboard==2.5.0
tensorflow==2.5.0

getting below error:

#10 242.3 The conflict is caused by:
#10 242.3     The user requested numpy
#10 242.3     altair 4.1.0 depends on numpy
#10 242.3     cmdstanpy 1.0.8 depends on numpy>=1.21
#10 242.3     h5py 3.1.0 depends on numpy>=1.19.3; python_version >= "3.9"
#10 242.3     keras-preprocessing 1.1.2 depends on numpy>=1.9.1
#10 242.3     matplotlib 3.4.2 depends on numpy>=1.16
#10 242.3     opt-einsum 3.3.0 depends on numpy>=1.7
#10 242.3     pandas 1.2.4 depends on numpy>=1.16.5
#10 242.3     params-flow 0.8.2 depends on numpy
#10 242.3     patsy 0.5.3 depends on numpy>=1.4
#10 242.3     pmdarima 2.0.2 depends on numpy>=1.21.2
#10 242.3     prophet 1.1.1 depends on numpy>=1.15.4
#10 242.3     pydeck 0.6.2 depends on numpy>=1.16.4
#10 242.3     scikit-learn 0.24.2 depends on numpy>=1.13.3
#10 242.3     scipy 1.6.3 depends on numpy<1.23.0 and >=1.16.5
#10 242.3     seaborn 0.11.1 depends on numpy>=1.15
#10 242.3     statsmodels 0.13.5 depends on numpy>=1.17; python_version != "3.10" or 
platform_system != "Windows" or platform_python_implementation == "PyPy"
#10 242.3     streamlit 0.81.1 depends on numpy
#10 242.3     tensorboard 2.5.0 depends on numpy>=1.12.0
#10 242.3     tensorflow 2.5.0 depends on numpy~=1.19.2
#10 242.3
#10 242.3 To fix this you could try to:
#10 242.3 1. loosen the range of package versions you've specified
#10 242.3 2. remove package versions to allow pip attempt to solve the dependency conflict
#10 242.3
#10 242.3 ERROR: ResolutionImpossible: for help visit 
https://pip.pypa.io/en/latest/topics/dependency-resolution/#dealing-with-dependency-conflicts
------
executor failed running [/bin/sh -c pip install --default-timeout=100 future pip &&  hash pip 
&&  pip install --upgrade pip &&  hash pip &&  pip install -r requirements.txt]: exit code: 1

I removed the packages version, then it tried to download multiple versions and getting timed out.

I have python 3.9 in local system where i am creating requirements.txt using pip freeze > requirements.txt

any suggestions what’s going wrong?

2

Answers


  1. Probably the error could be related with pip version. You are using different version of pip in your local system and in Docker image. Make sure you are using the same pip version with your local system.

    You can try the following steps:

    • pip --version in your local system to get the local version (LOCAL_VERSION)
    • Then update the docker file with the specific version e.g pip install --upgrade pip==LOCAL_VERSION
    Login or Signup to reply.
  2. These 2 constraints seem incompatible:

    • cmdstanpy 1.0.8 depends on numpy>=1.21
    • tensorflow 2.5.0 depends on numpy~=1.19.2

    If I am not mistaken, ~=1.19.2 means >= 1.19.2, == 1.19.*, so it can not be anything in the in the 1.21 range (nor 1.20, 1.22, and so on) it has to be in 1.19.* but greater than 1.19.2.

    To solve this you could try to recreate the requirements.txt file from scratch. Maybe create a new virtual environment, let pip install all (direct) dependencies without the pinned versions, and then in case pip does manage to install everything without encountering any conflict you can re-freeze this solution into a fresh requirements.txt file.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search