在Docker容器中构建脚本时,我需要安装外部库。其中之一失败:
Step 2/6 : RUN pip install paho-mqtt logbook arrow requests ics
---> Running in 93d9144d6224
(...)
ERROR: ics 0.5 has requirement arrow<0.12,>=0.11, but you'll have arrow 0.15.2 which is incompatible.
Installing collected packages: paho-mqtt, logbook, six, python-dateutil, arrow, chardet, certifi, urllib3, idna, requests, ics
Successfully installed arrow-0.15.2 certifi-2019.9.11 chardet-3.0.4 ics-0.5 idna-2.8 logbook-1.5.2 paho-mqtt-1.4.0 python-dateutil-2.8.0 requests-2.22.0 six-1.12.0 urllib3-1.25.5
我不明白此错误:
在任何情况下(无论安装成功与否),此错误都会中断docker构建。
主要问题是为什么首先出现错误?
子问题:
如果还有其他有用信息,则整个构建日志:
Step 1/6 : FROM python:3.7-alpine
---> 39fb80313465
Step 2/6 : RUN pip install paho-mqtt logbook arrow requests ics
---> Running in 93d9144d6224
Collecting paho-mqtt
Downloading https://files.pythonhosted.org/packages/25/63/db25e62979c2a716a74950c9ed658dce431b5cb01fde29eb6cba9489a904/paho-mqtt-1.4.0.tar.gz (88kB)
Collecting logbook
Downloading https://files.pythonhosted.org/packages/6b/3f/f4e6693791efacc1282852fba5392da0649b19416b37422c5489f79a52ea/Logbook-1.5.2.tar.gz (85kB)
Collecting arrow
Downloading https://files.pythonhosted.org/packages/cc/f5/f618f8423fe674a60461e58683edfeead93f4bbf95b9fca0e9699e765b35/arrow-0.15.2-py2.py3-none-any.whl (40kB)
Collecting requests
Downloading https://files.pythonhosted.org/packages/51/bd/23c926cd341ea6b7dd0b2a00aba99ae0f828be89d72b2190f27c11d4b7fb/requests-2.22.0-py2.py3-none-any.whl (57kB)
Collecting ics
Downloading https://files.pythonhosted.org/packages/3a/66/7844baa915da9a76ef7b7b6d93935cc1474688c6ea914b90dbe54d6f6f41/ics-0.5-py2.py3-none-any.whl
Collecting python-dateutil (from arrow)
Downloading https://files.pythonhosted.org/packages/41/17/c62faccbfbd163c7f57f3844689e3a78bae1f403648a6afb1d0866d87fbb/python_dateutil-2.8.0-py2.py3-none-any.whl (226kB)
Collecting chardet<3.1.0,>=3.0.2 (from requests)
Downloading https://files.pythonhosted.org/packages/bc/a9/01ffebfb562e4274b6487b4bb1ddec7ca55ec7510b22e4c51f14098443b8/chardet-3.0.4-py2.py3-none-any.whl (133kB)
Collecting certifi>=2017.4.17 (from requests)
Downloading https://files.pythonhosted.org/packages/18/b0/8146a4f8dd402f60744fa380bc73ca47303cccf8b9190fd16a827281eac2/certifi-2019.9.11-py2.py3-none-any.whl (154kB)
Collecting urllib3!=1.25.0,!=1.25.1,<1.26,>=1.21.1 (from requests)
Downloading https://files.pythonhosted.org/packages/81/b7/cef47224900ca67078ed6e2db51342796007433ad38329558f56a15255f5/urllib3-1.25.5-py2.py3-none-any.whl (125kB)
Collecting idna<2.9,>=2.5 (from requests)
Downloading https://files.pythonhosted.org/packages/14/2c/cd551d81dbe15200be1cf41cd03869a46fe7226e7450af7a6545bfc474c9/idna-2.8-py2.py3-none-any.whl (58kB)
Collecting six>1.5 (from ics)
Downloading https://files.pythonhosted.org/packages/73/fb/00a976f728d0d1fecfe898238ce23f502a721c0ac0ecfedb80e0d88c64e9/six-1.12.0-py2.py3-none-any.whl
Building wheels for collected packages: paho-mqtt, logbook
Building wheel for paho-mqtt (setup.py): started
Building wheel for paho-mqtt (setup.py): finished with status 'done'
Created wheel for paho-mqtt: filename=paho_mqtt-1.4.0-cp37-none-any.whl size=48332 sha256=56275b1fa3496506436d27287c83cde7c59ec350292f87edd45f0248f8ef46e5
Stored in directory: /root/.cache/pip/wheels/82/e5/de/d90d0f397648a1b58ffeea1b5742ac8c77f71fd43b550fa5a5
Building wheel for logbook (setup.py): started
Building wheel for logbook (setup.py): finished with status 'done'
Created wheel for logbook: filename=Logbook-1.5.2-cp37-cp37m-linux_x86_64.whl size=66345 sha256=1a1f099a9baeaab15f43814c6506f3fc640c49add0fb8fafeb93397de9cd34b6
Stored in directory: /root/.cache/pip/wheels/c7/d6/22/9f6bd2884a48b215fdd9cbfa78671b51f4470dfd3d14ef701a
Successfully built paho-mqtt logbook
ERROR: ics 0.5 has requirement arrow<0.12,>=0.11, but you'll have arrow 0.15.2 which is incompatible.
Installing collected packages: paho-mqtt, logbook, six, python-dateutil, arrow, chardet, certifi, urllib3, idna, requests, ics
Successfully installed arrow-0.15.2 certifi-2019.9.11 chardet-3.0.4 ics-0.5 idna-2.8 logbook-1.5.2 paho-mqtt-1.4.0 python-dateutil-2.8.0 requests-2.22.0 six-1.12.0 urllib3-1.25.5
Removing intermediate container 93d9144d6224
---> 7a3f016d1374
答案 0 :(得分:1)
没有看到您的Dockerfile
,我们真的看不到您在做什么;但是
pip install arrow==0.11
代替pip install arrow
应该可以解决当前的问题。
如果RUN
语句中的命令用&&
分隔,则可以在要忽略其错误的命令之后将其更改为;
,并可以添加{{1} },以使整个|| true
语句始终成功;但这通常是不好的做法,在这种情况下,无论如何都不会产生有用的图像。
答案 1 :(得分:0)
您有一个名为ics
的模块,该模块对版本为arrow
的{{1}}模块具有依赖性,在构建python模块时会指定这些依赖性版本。构建docker映像时,它正在使用缓存中的<0.12,>=0.11
,因为它可能已经安装在您的计算机上。
处理这些类型的错误的最佳方法是在arrow 0.15.2
文件中定义所有依赖及其版本,并运行requirements.txt
一次安装所有依赖。
我不能肯定地说为什么您的构建失败。您可以尝试卸载pip install -r requirements.txt
模块并重新安装指定的版本。