python - 由于 python greenlet 包,Docker 构建崩溃

标签 python python-2.7 docker greenlets

我正在尝试从现有的 Dockerfile 创建 Docker 容器,但由于 greenlet 包而失败。该容器是之前(1-2 年前)构建的,并且在远程服务器上运行良好,但是当我尝试在本地或另一台云计算机上再次构建时,它会失败。非常感谢任何帮助。

这是 Dockerfile

FROM python:2.7-alpine

RUN apk update && apk add \
        postgresql-dev \
        python3-dev \
        gcc \
        jpeg-dev \
        zlib-dev \
        musl-dev \
        linux-headers && \
        mkdir app

WORKDIR /app/

# Ensure that Python outputs everything that's printed inside
# the application rather than buffering it.
ENV PYTHONUNBUFFERED 1

ADD . /app

RUN if [ -s requirements.txt ]; then pip install -r requirements.txt; fi
EXPOSE 8092
VOLUME /app/auction/assets
ENTRYPOINT ["/usr/local/bin/uwsgi", "--ini", "/app/uwsgi.ini"]

这是我收到的错误:

#10 64.38 Successfully built logutils psycopg2 Pillow django-endless-pagination django-templated-email xlrd plivo uWSGI billiard anyjson
#10 64.38 Failed to build greenlet
#10 64.60 Installing collected packages: Django, urllib3, idna, chardet, certifi, requests, greenlet, pygments, six, typing, backports.functools-lru-cache, wcwidth, blessings, curtsies, bpython, django-braces, django-model-utils, logutils, psycopg2, Pillow, django-multiupload, django-endless-pagination, python-dateutil, django-templated-email, billiard, pytz, amqp, anyjson, kombu, redis, celery, sorl-thumbnail, xlrd, plivo, uWSGI
#10 68.78     Running setup.py install for greenlet: started
#10 69.83     Running setup.py install for greenlet: finished with status 'error'
#10 69.83     ERROR: Command errored out with exit status 1:
#10 69.83      command: /usr/local/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-GNyJHs/greenlet/setup.py'"'"'; __file__='"'"'/tmp/pip-install-GNyJHs/greenlet/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-VFmzYm/install-record.txt --single-version-externally-managed --compile --install-headers /usr/local/include/python2.7/greenlet
#10 69.83          cwd: /tmp/pip-install-GNyJHs/greenlet/
#10 69.83     Complete output (82 lines):
#10 69.83     running install
#10 69.83     running build
#10 69.83     running build_py
#10 69.83     creating build
#10 69.83     creating build/lib.linux-x86_64-2.7
#10 69.83     creating build/lib.linux-x86_64-2.7/greenlet
#10 69.83     copying src/greenlet/__init__.py -> build/lib.linux-x86_64-2.7/greenlet
#10 69.83     creating build/lib.linux-x86_64-2.7/greenlet/tests
#10 69.83     copying src/greenlet/tests/test_cpp.py -> build/lib.linux-x86_64-2.7/greenlet/tests
#10 69.83     copying src/greenlet/tests/__init__.py -> build/lib.linux-x86_64-2.7/greenlet/tests
#10 69.83     copying src/greenlet/tests/test_gc.py -> build/lib.linux-x86_64-2.7/greenlet/tests
#10 69.83     copying src/greenlet/tests/test_greenlet.py -> build/lib.linux-x86_64-2.7/greenlet/tests
#10 69.83     copying src/greenlet/tests/test_tracing.py -> build/lib.linux-x86_64-2.7/greenlet/tests
#10 69.83     copying src/greenlet/tests/test_generator.py -> build/lib.linux-x86_64-2.7/greenlet/tests
#10 69.83     copying src/greenlet/tests/test_contextvars.py -> build/lib.linux-x86_64-2.7/greenlet/tests
#10 69.83     copying src/greenlet/tests/test_extension_interface.py -> build/lib.linux-x86_64-2.7/greenlet/tests
#10 69.83     copying src/greenlet/tests/test_version.py -> build/lib.linux-x86_64-2.7/greenlet/tests
#10 69.83     copying src/greenlet/tests/test_generator_nested.py -> build/lib.linux-x86_64-2.7/greenlet/tests
#10 69.83     copying src/greenlet/tests/test_leaks.py -> build/lib.linux-x86_64-2.7/greenlet/tests
#10 69.83     copying src/greenlet/tests/test_weakref.py -> build/lib.linux-x86_64-2.7/greenlet/tests
#10 69.83     copying src/greenlet/tests/test_throw.py -> build/lib.linux-x86_64-2.7/greenlet/tests
#10 69.83     copying src/greenlet/tests/test_stack_saved.py -> build/lib.linux-x86_64-2.7/greenlet/tests
#10 69.83     running egg_info
#10 69.83     writing requirements to src/greenlet.egg-info/requires.txt
#10 69.83     writing src/greenlet.egg-info/PKG-INFO
#10 69.83     writing top-level names to src/greenlet.egg-info/top_level.txt
#10 69.83     writing dependency_links to src/greenlet.egg-info/dependency_links.txt
#10 69.83     reading manifest file 'src/greenlet.egg-info/SOURCES.txt'
#10 69.83     reading manifest template 'MANIFEST.in'
#10 69.83     no previously-included directories found matching 'docs/_build'
#10 69.83     warning: no files found matching '*.py' under directory 'appveyor'
#10 69.83     warning: no previously-included files matching '*.pyc' found anywhere in distribution
#10 69.83     warning: no previously-included files matching '*.pyd' found anywhere in distribution
#10 69.83     warning: no previously-included files matching '*.so' found anywhere in distribution
#10 69.83     warning: no previously-included files matching '.coverage' found anywhere in distribution
#10 69.83     writing manifest file 'src/greenlet.egg-info/SOURCES.txt'
#10 69.83     copying src/greenlet/greenlet.c -> build/lib.linux-x86_64-2.7/greenlet
#10 69.83     copying src/greenlet/greenlet.h -> build/lib.linux-x86_64-2.7/greenlet
#10 69.83     copying src/greenlet/slp_platformselect.h -> build/lib.linux-x86_64-2.7/greenlet
#10 69.83     creating build/lib.linux-x86_64-2.7/greenlet/platform
#10 69.83     copying src/greenlet/platform/setup_switch_x64_masm.cmd -> build/lib.linux-x86_64-2.7/greenlet/platform
#10 69.83     copying src/greenlet/platform/switch_aarch64_gcc.h -> build/lib.linux-x86_64-2.7/greenlet/platform
#10 69.83     copying src/greenlet/platform/switch_alpha_unix.h -> build/lib.linux-x86_64-2.7/greenlet/platform
#10 69.83     copying src/greenlet/platform/switch_amd64_unix.h -> build/lib.linux-x86_64-2.7/greenlet/platform
#10 69.83     copying src/greenlet/platform/switch_arm32_gcc.h -> build/lib.linux-x86_64-2.7/greenlet/platform
#10 69.83     copying src/greenlet/platform/switch_arm32_ios.h -> build/lib.linux-x86_64-2.7/greenlet/platform
#10 69.83     copying src/greenlet/platform/switch_csky_gcc.h -> build/lib.linux-x86_64-2.7/greenlet/platform
#10 69.83     copying src/greenlet/platform/switch_m68k_gcc.h -> build/lib.linux-x86_64-2.7/greenlet/platform
#10 69.83     copying src/greenlet/platform/switch_mips_unix.h -> build/lib.linux-x86_64-2.7/greenlet/platform
#10 69.83     copying src/greenlet/platform/switch_ppc64_aix.h -> build/lib.linux-x86_64-2.7/greenlet/platform
#10 69.83     copying src/greenlet/platform/switch_ppc64_linux.h -> build/lib.linux-x86_64-2.7/greenlet/platform
#10 69.83     copying src/greenlet/platform/switch_ppc_aix.h -> build/lib.linux-x86_64-2.7/greenlet/platform
#10 69.83     copying src/greenlet/platform/switch_ppc_linux.h -> build/lib.linux-x86_64-2.7/greenlet/platform
#10 69.83     copying src/greenlet/platform/switch_ppc_macosx.h -> build/lib.linux-x86_64-2.7/greenlet/platform
#10 69.83     copying src/greenlet/platform/switch_ppc_unix.h -> build/lib.linux-x86_64-2.7/greenlet/platform
#10 69.83     copying src/greenlet/platform/switch_riscv_unix.h -> build/lib.linux-x86_64-2.7/greenlet/platform
#10 69.83     copying src/greenlet/platform/switch_s390_unix.h -> build/lib.linux-x86_64-2.7/greenlet/platform
#10 69.83     copying src/greenlet/platform/switch_sparc_sun_gcc.h -> build/lib.linux-x86_64-2.7/greenlet/platform
#10 69.83     copying src/greenlet/platform/switch_x32_unix.h -> build/lib.linux-x86_64-2.7/greenlet/platform
#10 69.83     copying src/greenlet/platform/switch_x64_masm.asm -> build/lib.linux-x86_64-2.7/greenlet/platform
#10 69.83     copying src/greenlet/platform/switch_x64_masm.obj -> build/lib.linux-x86_64-2.7/greenlet/platform
#10 69.83     copying src/greenlet/platform/switch_x64_msvc.h -> build/lib.linux-x86_64-2.7/greenlet/platform
#10 69.83     copying src/greenlet/platform/switch_x86_msvc.h -> build/lib.linux-x86_64-2.7/greenlet/platform
#10 69.83     copying src/greenlet/platform/switch_x86_unix.h -> build/lib.linux-x86_64-2.7/greenlet/platform
#10 69.83     copying src/greenlet/tests/_test_extension.c -> build/lib.linux-x86_64-2.7/greenlet/tests
#10 69.83     copying src/greenlet/tests/_test_extension_cpp.cpp -> build/lib.linux-x86_64-2.7/greenlet/tests
#10 69.83     running build_ext
#10 69.83     building 'greenlet._greenlet' extension
#10 69.83     creating build/temp.linux-x86_64-2.7
#10 69.83     creating build/temp.linux-x86_64-2.7/src
#10 69.83     creating build/temp.linux-x86_64-2.7/src/greenlet
#10 69.83     gcc -fno-strict-aliasing -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -DTHREAD_STACK_SIZE=0x100000 -fPIC -I/usr/local/include/python2.7 -c src/greenlet/greenlet.c -o build/temp.linux-x86_64-2.7/src/greenlet/greenlet.o
#10 69.83     gcc -shared build/temp.linux-x86_64-2.7/src/greenlet/greenlet.o -L/usr/local/lib -lpython2.7 -o build/lib.linux-x86_64-2.7/greenlet/_greenlet.so
#10 69.83     building 'greenlet.tests._test_extension' extension
#10 69.83     creating build/temp.linux-x86_64-2.7/src/greenlet/tests
#10 69.83     gcc -fno-strict-aliasing -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -DTHREAD_STACK_SIZE=0x100000 -fPIC -Isrc/greenlet/ -I/usr/local/include/python2.7 -c src/greenlet/tests/_test_extension.c -o build/temp.linux-x86_64-2.7/src/greenlet/tests/_test_extension.o
#10 69.83     gcc -shared build/temp.linux-x86_64-2.7/src/greenlet/tests/_test_extension.o -L/usr/local/lib -lpython2.7 -o build/lib.linux-x86_64-2.7/greenlet/tests/_test_extension.so
#10 69.83     building 'greenlet.tests._test_extension_cpp' extension
#10 69.83     gcc -fno-strict-aliasing -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -DTHREAD_STACK_SIZE=0x100000 -fPIC -Isrc/greenlet/ -I/usr/local/include/python2.7 -c src/greenlet/tests/_test_extension_cpp.cpp -o build/temp.linux-x86_64-2.7/src/greenlet/tests/_test_extension_cpp.o
#10 69.83     gcc: fatal error: cannot execute 'cc1plus': execvp: No such file or directory
#10 69.83     compilation terminated.
#10 69.83     error: command 'gcc' failed with exit status 1
#10 69.83     ----------------------------------------
#10 70.42 ERROR: Command errored out with exit status 1: /usr/local/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-GNyJHs/greenlet/setup.py'"'"'; __file__='"'"'/tmp/pip-install-GNyJHs/greenlet/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-VFmzYm/install-record.txt --single-version-externally-managed --compile --install-headers /usr/local/include/python2.7/greenlet Check the logs for full command output.
#10 70.90 WARNING: You are using pip version 20.0.2; however, version 20.3.4 is available.
#10 70.90 You should consider upgrading via the '/usr/local/bin/python -m pip install --upgrade pip' command.
------
executor failed running [/bin/sh -c if [ -s requirements.txt ]; then pip install -r requirements.txt; fi]: exit code: 1

最佳答案

我也遇到了同样的问题,但使用的是基本 Python 镜像 python:3.7.4-alpine3.10。 SQLAlchemy 最近发布的一个版本似乎是问题的根源。

为了解决这个问题,我只是从需求文件中删除了包并构建了一个空容器。我单独运行安装,发现 SQLAlchemy 及其依赖项需要固定到之前的版本。

我的需求文件失败了:

Flask==1.1.2
Flask-Ext==0.1
Flask-Script
flask-cors
flask-login
Flask-Migrate
mysql-connector-python
python-dotenv
sqlalchemy
pytest-flask

安装的更新版本:

Flask==1.1.2
Flask-Ext==0.1
Flask-Script
flask-cors
flask-login
Flask-SQLAlchemy==2.4.4
Flask-Migrate==2.6.0
mysql-connector-python
python-dotenv
sqlalchemy==1.3.23
pytest-flask

关于python - 由于 python greenlet 包,Docker 构建崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66768490/

相关文章:

python - 如何限制 Python 类上可用的属性

python-2.7 - 如何通过 Selenium Python 点击​​某个元素

apache - 构建容器Ubuntu 14.04并安装apache2时如何解决 "invoke-rc.d: policy-rc.d denied execution of start."?

docker - 错误 : repository [dockerimage] not found: does not exist or no pull access-docker

Docker - 在源文件中构建 Arg

python - 从排列生成器中随机选择?

python - 装饰器可以访问类的私有(private)成员吗?

python - 没有拦截的 Sklearn RANSAC

python - OpenCV错误:参数-p/-prototxt是必需的

Python RE 搜索数字和小数