[英]not able to install packages with requirements.txt in docker
i am creating image with below dockerfile:我正在使用以下 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
我在本地系统中有
python 3.9
,我正在使用pip freeze > requirements.txt
创建requirements.txt
any suggestions what's going wrong?有什么建议出了什么问题吗?
Probably the error could be related with pip version.错误可能与 pip 版本有关。 You are using different version of pip in your local system and in Docker image.
您在本地系统和 Docker 图像中使用不同版本的 pip。 Make sure you are using the same pip version with your local system.
确保您使用与本地系统相同的 pip 版本。
You can try the following steps:您可以尝试以下步骤:
pip --version
in your local system to get the local version ( LOCAL_VERSION
) pip --version
in your local system 获取本地版本 ( LOCAL_VERSION
)pip install --upgrade pip==LOCAL_VERSION
pip install --upgrade pip==LOCAL_VERSION
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
.如果我没记错的话,
~=1.19.2
意味着>= 1.19.2, == 1.19.*
,所以它不能是1.21
范围内的任何东西(也不是1.20
、 1.22
等等)它必须是在1.19.*
但大于1.19.2
。
To solve this you could try to recreate the requirements.txt
file from scratch.要解决此问题,您可以尝试从头开始重新创建
requirements.txt
文件。 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.也许创建一个新的虚拟环境,让
pip
在没有固定版本的情况下安装所有(直接)依赖项,然后如果pip
确实设法安装所有内容而没有遇到任何冲突,您可以将此解决方案重新冻结到一个新的requirements.txt
文件中。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.