首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在本地venv中运行时,在docker中获取requirments.txt文件的版本冲突不会发生

在本地venv中运行时,在docker中获取requirments.txt文件的版本冲突不会发生
EN

Stack Overflow用户
提问于 2021-09-27 09:56:00
回答 1查看 428关注 0票数 0

当我试图构建一个dockerfile时,会遇到版本冲突。当我在本地venv中运行pip -r requirements.txt时,不会发生这种情况。在安装后,我在本地的静脉中运行了pipdeptree,没有发现冲突。只有当我试图通过eb cli与码头构建时,才会发生这种情况。

我在开码头-CE19.03.9。本地venv和dockerfile都配置为运行Python3.6。我一直无法联系到原来的开发人员,我不太熟悉对接,所以我不知道从这里到哪里,除了安装不同版本的对接,并再次尝试。

应要求,这是停靠文件;

代码语言:javascript
复制
FROM       python:3.6

WORKDIR    /var/app

RUN        pip3 install virtualenv
RUN        virtualenv /var/app
RUN        /var/app/bin/pip install --upgrade pip
RUN        /var/app/bin/pip install uwsgi

RUN        useradd uwsgi -s /bin/false
RUN        mkdir /var/log/uwsgi
RUN        chown -R uwsgi:uwsgi /var/log/uwsgi

ADD        ./requirements.txt /var/app
RUN        /var/app/bin/pip install -r /var/app/requirements.txt

ADD        . /var/app

<env stuff for uwsgi>

EXPOSE     8080

ADD        uwsgi-start.sh /

CMD        []
ENTRYPOINT ["/uwsgi-start.sh"]

要求清单如下;

代码语言:javascript
复制
appnope==0.1.0
astroid==1.6.1
autopep8==1.3.4
awscli==1.16.46
backcall==0.1.0
bleach==2.1.3
boto3==1.5.34
botocore==1.12.36
Cerberus==0.9.2
certifi==2018.4.16
cffi==1.11.4
chardet==3.0.4
click==6.7
decorator==4.3.0
dnspython==1.15.0
docutils==0.14
dominate==2.3.1
ecdsa==0.13
entrypoints==0.2.3
envs==1.2.4
Eve==0.7.8
Eve-Swagger==0.0.8
Events==0.2.2
Faker==0.8.13
flake8==3.5.0
Flask==0.12.2
Flask-Bootstrap==3.3.7.1
Flask-Cors==3.0.3
flask-nav==0.6
Flask-PyMongo==0.5.1
future==0.16.0
gunicorn==19.7.1
html5lib==1.0.1
httplib2==0.10.3
idna==2.6
ipykernel==4.8.2
ipython==6.3.1
ipython-genutils==0.2.0
ipywidgets==7.2.1
isort==4.3.4
itsdangerous==0.24
jedi==0.12.0
Jinja2==2.10
jmespath==0.9.3
jsonschema==2.6.0
jupyter==1.0.0
jupyter-client==5.2.3
jupyter-console==5.2.0
jupyter-core==4.4.0
lazy-object-proxy==1.3.1
MarkupSafe==1.1.0
mccabe==0.6.1
mistune==0.8.3
nbconvert==5.3.1
nbformat==4.4.0
notebook==5.4.1
numpy==1.14.2
oauth2client==4.1.2
pandas==0.22.0
pandocfilters==1.4.2
parso==0.2.0
pexpect==4.5.0
pickleshare==0.7.4
pkginfo==1.4.2
prompt-toolkit==1.0.15
ptyprocess==0.5.2
pyasn1==0.4.2
pyasn1-modules==0.2.1
pycodestyle==2.3.1
pycparser==2.18
pycryptodome==3.6.1
pyflakes==1.6.0
Pygments==2.2.0
PyJWT==1.6.1
pylint==1.8.2
pymongo==3.6.0
python-dateutil==2.7.2
python-http-client==3.0.0
python-jose-cryptodome==1.3.2
pytz==2018.4
PyYAML==3.13
pyzmq==17.0.0
qtconsole==4.3.1
readme-renderer==24.0
requests==2.18.4
requests-toolbelt==0.8.0
rsa==3.4.2
s3transfer==0.1.13
Send2Trash==1.5.0
sendgrid==5.3.0
simplegeneric==0.8.1
simplejson==3.13.2
six==1.11.0
stringcase==1.2.0
terminado==0.8.1
testpath==0.3.1
text-unidecode==1.2
tornado==5.0.2
tqdm==4.28.1
traitlets==4.3.2
urllib3==1.22
visitor==0.1.3
warrant==0.6.1
watchtower==0.5.3
wcwidth==0.1.7
webencodings==0.5.1
Werkzeug==0.14.1
widgetsnbextension==3.2.1
wrapt==1.10.11
xlrd==1.1.0
XlsxWriter==1.0.2

第一次冲突发生在awscli和boto3之间;

代码语言:javascript
复制
ERROR: Cannot install -r /var/app/requirements.txt (line 4), -r /var/app/requirements.txt (line 7) and botocore==1.12.36 because these package versions have conflicting dependencies.

The conflict is caused by:
    The user requested botocore==1.12.36
    awscli 1.16.46 depends on botocore==1.12.36
    boto3 1.5.34 depends on botocore<1.9.0 and >=1.8.48
To fix this you could try to:
1. loosen the range of package versions you've specified
2. remove package versions to allow pip attempt to solve the dependency conflict
ERROR: ResolutionImpossible: for help visit https://pip.pypa.io/en/latest/user_guide/#fixing-conflicting-dependencies

当我删除版本控制约束时,它就会发现一个错误-- werkzeug。

代码语言:javascript
复制
ERROR: Cannot install -r /var/app/requirements.txt (line 22) and Werkzeug==0.14.1 because these package versions have conflicting dependencies.

The conflict is caused by:
    The user requested Werkzeug==0.14.1
    eve 0.7.8 depends on werkzeug<=0.11.15 and >=0.9.4
To fix this you could try to:
1. loosen the range of package versions you've specified
2. remove package versions to allow pip attempt to solve the dependency conflict
ERROR: ResolutionImpossible: for help visit https://pip.pypa.io/en/latest/user_guide/#fixing-conflicting-dependencies
The command '/bin/sh -c /var/app/bin/pip install -r /var/app/requirements.txt' returned a non-zero code: 1

当我试图解决冲突的时候,越来越多的人出现了。大约有一打左右。我无法更改依赖项要求,因为这可能会破坏应用程序,而且我也没有足够的时间尝试更新这些更改的代码库。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2021-09-27 12:09:33

说明Pip帮助你解释发生了什么,确实有点多毛的情况。

已经有一个Bean秸秆应用程序正在运行EC2s,它的对接器容器能够很好地满足这些需求,所以我不知道为什么现在会发生这种情况。

至于“为什么现在会发生这种情况”--我能想到两件事:

  • 基本映像中的Pip版本已经更新;较新的版本在冲突的依赖项上更聪明(因为它们拒绝安装可能/不应该工作的包星座)。
  • 因为您的requirements.txt不一定是完全的锁住;在文件中没有列出的传递依赖项是不兼容的。

但是,既然您已经有了工作容器映像,那就太好了!你可以简单地

代码语言:javascript
复制
$ mv requirements.txt requirements.in
$ docker run -it thatcontainerimage /var/app/bin/pip freeze -l > requirements.txt

  • 首先,将您的“模板”要求(例如,pip-tools (我喜欢的依赖项锁定工具)使用的)移到requirements.in上,并且
  • 获取从容器到“锁定”requirements.txt文件的实际安装包的完整列表。

希望该需求文件能够很好地安装。如果这仍然失败,(糟糕的)解决方法是在单独的pip调用中安装每个需求;Pip随后会警告相互冲突的依赖关系,但不会拒绝安装它们.

不过,作为一个旁白:

  • 当您同时使用显式Werkzeug==0.14.1 `的Eve==0.7.8时,您确定要在需求中显式地指定没有任何比Werkzeug 0.11更新的工作吗?(这同样代表MarkupSafe和烧瓶的版本。)
  • 您确定您的生产应用程序映像需要awscli吗?或者autopep8pylint?或者gunicorn,如果你在运行uwsgi的话?所有那些笔记本相关的包裹?您应该将您的需求缩减到单独的集合,例如开发和测试,以及运行时.
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/69344685

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档