Docker pip3没有安装包

问题描述 投票:0回答:1

我有以下Dockerfile和requirements.txt文件。 requirements.txt似乎已被处理,但我没有看到任何输出“安装收集的包”语句,就像我在没有Docker的系统上安装软件包时看到的那样。在docker构建中,我最终会遇到一个错误,其中应该安装了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 output

...
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
python docker pip
1个回答
2
投票

按照设计,pip不会安装任何包装,直到它收集并构建轮子用于它要安装的所有东西;这样做是为了防止安装过程中的故障导致只安装一些软件包。因此,在你的情况下,在为cython构建一个轮子之前不会安装pdfparser,这显然需要cython才能构建,因此安装失败。您需要在两个单独的步骤中安装cythonpdfparser

© www.soinside.com 2019 - 2024. All rights reserved.