[英]Python error when building Python package Docker Image
I have installed Docker on a RHEL7 server and it is running.我已经在 RHEL7 服务器上安装了 Docker,它正在运行。 I am trying to build my first Docker Image that I found on GitHub to build a python library docker image for use with Demisto.
我正在尝试构建我在 GitHub 上找到的第一个 Docker 镜像,以构建一个用于 Demisto 的 python 库 docker 镜像。 https://github.com/demisto/tools/tree/master/docker
https://github.com/demisto/tools/tree/master/docker
I modified the requirements folder and just added one python package, impyla.我修改了 requirements 文件夹,只添加了一个 python 包,impyla。 As you can see below it downloads and impyla and its dependencies but then returns an error message, but I am not sure what to do now.
正如您在下面看到的那样,它下载了 impyla 及其依赖项,但随后返回了一条错误消息,但我不确定现在该怎么做。 Does anybody with docker and or python experience know what I should try next?
有 docker 和/或 python 经验的人知道我接下来应该尝试什么吗?
[root@localhost docker]# sudo ./create_docker_image.sh dockerstuff/docker_python_image
Sending build context to Docker daemon 48.13kB
Step 1/3 : FROM python:2.7.15-slim-jessie
---> af47402d957b
Step 2/3 : COPY requirements.txt .
---> Using cache
---> e107910d781c
Step 3/3 : RUN pip install --no-cache-dir -r requirements.txt
---> Running in 41e182aee016
Collecting impyla (from -r requirements.txt (line 1))
Downloading https://files.pythonhosted.org/packages/6f/96/92f933cd216f9ff5d7f4ba7e0615a51ad4e3beb31a7de60f7df365378bb9/impyla-0.14.1-py2-none-any.whl (165kB)
Collecting six (from impyla->-r requirements.txt (line 1))
Downloading https://files.pythonhosted.org/packages/73/fb/00a976f728d0d1fecfe898238ce23f502a721c0ac0ecfedb80e0d88c64e9/six-1.12.0-py2.py3-none-any.whl
Collecting bitarray (from impyla->-r requirements.txt (line 1))
Downloading https://files.pythonhosted.org/packages/e2/1e/b93636ae36d08d0ee3aec40b08731cc97217c69db9422c0afef6ee32ebd2/bitarray-0.8.3.tar.gz
Collecting thrift<=0.9.3 (from impyla->-r requirements.txt (line 1))
Downloading https://files.pythonhosted.org/packages/ae/58/35e3f0cd290039ff862c2c9d8ae8a76896665d70343d833bdc2f748b8e55/thrift-0.9.3.tar.gz
Installing collected packages: six, bitarray, thrift, impyla
Running setup.py install for bitarray: started
Running setup.py install for bitarray: finished with status 'error'
Complete output from command /usr/local/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-install-1p5nQr/bitarray/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-record-U39Tv0/install-record.txt --single-version-externally-managed --compile:
running install
running build
running build_py
creating build
creating build/lib.linux-x86_64-2.7
creating build/lib.linux-x86_64-2.7/bitarray
copying bitarray/__init__.py -> build/lib.linux-x86_64-2.7/bitarray
copying bitarray/test_bitarray.py -> build/lib.linux-x86_64-2.7/bitarray
running build_ext
building 'bitarray._bitarray' extension
creating build/temp.linux-x86_64-2.7/bitarray
gcc -pthread -fno-strict-aliasing -g -02 -DNDEBUG -g -fwrapv -03 -Wall -Wstrict-prototypes -fPIC -I/usr/local/include/python2.7 -c bitarray/_bitarray.c -o build/temp.linux-x86_64-2.7/bitarray/_bitarray.o
unable to execute 'gcc': No such file or directory
error: command 'gcc' failed with exit status 1
------------------------------------------
Command "/usr/local/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-install-1p5nQr/bitarray/setup.py';f=getattr(tokensize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-record-U39Tv0/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-install-1p5nQr/bitarray/
The command '/bin/sh -c pip install --no-cache-dir -r requirements.txt' returned a non-zero code: 1
Basically you have to add all the dependencies yourself.基本上你必须自己添加所有依赖项。 Line 2 is what I added I have just modified the Dockerfile and built it myself.
第 2 行是我添加的我刚刚修改了 Dockerfile 并自己构建了它。 It works.
有用。 Let me know if you have any questions.
如果您有任何问题,请告诉我。
FROM python:2.7.15-slim-jessie
RUN apt-get update -y && apt-get install apt-file -y && apt-file update -y && apt-get install -y python3-dev build-essential
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
This is for anyone who is using a continuumio/miniconda3:latest
based image and encountered the unable to execute 'gcc'
error.这适用于使用基于
continuumio/miniconda3:latest
的图像并遇到unable to execute 'gcc'
错误的任何人。 I added the following line to my Dockerfile, and it is all that I minimally needed:我将以下行添加到我的 Dockerfile 中,这是我最低限度需要的:
RUN apt-get update && apt-get -y install gcc
Note that the above image in turn uses debian:latest
.请注意,上图依次使用
debian:latest
。 Also, I didn't need all of build-essential
.另外,我不需要所有的
build-essential
。
python3-dev
and build-essential
should satisfy most build needs including gcc
. python3-dev
和build-essential
应该满足大多数构建需求,包括gcc
。
FROM python:3.6.13-slim
WORKDIR /app
COPY . .
RUN apt update -y && apt-get install -y python3-dev build-essential && \
pip install -r requirements.txt
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.