Docker pip3未安装软件包

时间:2018-09-04 20:17:21

标签: python docker pip

我有以下Dockerfile和requirements.txt文件。 requirements.txt似乎正在处理中,但是没有看到任何输出“正在安装收集的软件包”的语句,就像我在没有Docker的系统上安装软件包时看到的那样。在docker build中,我最终遇到一个错误,该错误是应已安装requirements.txt中的先前软件包。

Dockerfile

FROM alpine:3.8
ADD . /code
RUN apk add alpine-sdk python3-dev
WORKDIR /code
RUN sudo apk update
RUN pip3 install --trusted-host pypi.python.org -r requirements.txt
CMD ["python3", "linqcmd"]

requirements.txt

boto3
click
python-levenshtein
python-dateutil
cython
# pip3 install git+https://github.com/izderadicka/pdfparser
-e git://github.com/izderadicka/pdfparser.git#egg=pdfparser

docker-compose up --build输出

...
Step 6/7 : RUN pip3 install --trusted-host pypi.python.org -r requirements.txt
 ---> Running in 515dd716aa7c
Collecting boto3 (from -r requirements.txt (line 4))
  Downloading https://files.pythonhosted.org/packages/a8/45/810f786ce144bfd19d9f2f700a8cd4358435559a2b88b2c235f7bb3f29df/boto3-1.8.6-py2.py3-none-any.whl (128kB)
Collecting click (from -r requirements.txt (line 5))
  Downloading https://files.pythonhosted.org/packages/34/c1/8806f99713ddb993c5366c362b2f908f18269f8d792aff1abfd700775a77/click-6.7-py2.py3-none-any.whl (71kB)
Collecting python-levenshtein (from -r requirements.txt (line 6))
  Downloading https://files.pythonhosted.org/packages/42/a9/d1785c85ebf9b7dfacd08938dd028209c34a0ea3b1bcdb895208bd40a67d/python-Levenshtein-0.12.0.tar.gz (48kB)
Collecting python-dateutil (from -r requirements.txt (line 7))
  Downloading https://files.pythonhosted.org/packages/cf/f5/af2b09c957ace60dcfac112b669c45c8c97e32f94aa8b56da4c6d1682825/python_dateutil-2.7.3-py2.py3-none-any.whl (211kB)
Collecting cython (from -r requirements.txt (line 8))
  Downloading https://files.pythonhosted.org/packages/21/89/ca320e5b45d381ae0df74c4b5694f1471c1b2453c5eb4bac3449f5970481/Cython-0.28.5.tar.gz (1.9MB)
Obtaining pdfparser from git+git://github.com/izderadicka/pdfparser.git#egg=pdfparser (from -r requirements.txt (line 10))
  Cloning git://github.com/izderadicka/pdfparser.git to ./src/pdfparser
    Complete output from command python setup.py egg_info:
    You need to install cython first - sudo pip install cython

    ----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /code/src/pdfparser/
You are using pip version 10.0.1, however version 18.0 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
ERROR: Service 'web' failed to build: The command '/bin/sh -c pip3 install --trusted-host pypi.python.org -r requirements.txt' returned a non-zero code: 1

1 个答案:

答案 0 :(得分:2)

根据设计,pip不会收集任何软件包,直到将其收集并建造好轮子以安装将要安装的所有东西为止;这样做是为了防止安装过程中的失败导致仅安装某些软件包。因此,在您的情况下,cython不会在为pdfparser建造车轮之前安装,而车轮显然需要cython才能建造,因此安装失败。您需要分两个步骤安装cythonpdfparser

相关问题