这是当前场景、docker文件、需求和错误。有线索吗?这是一个带有flask的大型python web应用程序,我们希望将其dockerize。问题发生在库依赖项安装期间,特别是kiwisolver。见下文
Dockerfile:
FROM python:3.8-alpine
RUN adduser -D ddc-user
WORKDIR /ddc
COPY . /ddc
RUN python -m venv venv
RUN venv/bin/pip install --upgrade pip
RUN echo "http://dl-8.alpinelinux.org/alpine/edge/community" >> /etc/apk/repositories \
&& apk --no-cache --update-cache add postgresql-dev g++ linux-headers gfortran libffi-dev openssl-dev gcc build-base bash libpng-dev openblas-dev wget freetype-dev python3-dev py3-pip \
&& ln -s /usr/include/locale.h /usr/include/xlocale.h \
&& pip install setuptools wheel \
&& pip install numpy pyyaml
RUN apk add --no-cache --virtual .build-deps gcc musl-dev
RUN pip install cython
RUN apk del .build-deps gcc musl-dev
RUN venv/bin/pip install -r requirements.txt
RUN chmod +x boot.sh
ENV FLASK_APP main.py
RUN chown -R ddc-user:users ./
USER ddc-user
EXPOSE 5000
ENTRYPOINT ["./boot.sh"]
Requirements.txt:
alembic==0.9.9
blinker==1.4
chardet==3.0.4
click==6.7
Flask==1.0.2
Flask-Dance==0.14.0
Flask-DebugToolbar==0.10.1
Flask-Login==0.4.1
Flask-Migrate==2.1.1
Flask-OAuth==0.12
Flask-OAuthlib==0.9.4
Flask-SQLAlchemy==2.3.2
Flask-WTF==0.14.2
httplib2==0.11.3
idna==2.6
itsdangerous==0.24
Jinja2>=2.11.1
lazy==1.3
Mako==1.0.7
MarkupSafe==1.1.1
oauth2==1.9.0.post1
oauthlib==2.0.7
python-dateutil>=2.7.3
python-editor==1.0.3
requests==2.23.0
requests-oauthlib==0.8.0
SQLAlchemy==1.3.13
SQLAlchemy-Utils==0.33.2
urllib3==1.22
URLObject==2.4.3
Werkzeug==0.14.1
wincertstore==0.2
WTForms==2.1
Blueprint==3.4.2
google-cloud>=0.34.0
google-cloud-storage>=1.24.1
google-cloud-bigquery>=1.23.1
Flask-Bootstrap==3.3.7.1
six==1.13.0
flask-mail>=0.9.1
Markdown==2.6.8
itsdangerous==0.24
bleach==2.0.0
Flask-SSLify==0.1.5
gunicorn==19.7.1
gcsfs==0.3.0
cffi==1.13.2
pandas>=0.25.3
psycopg2==2.7.3
cloudstorage==0.10.0
vdm==0.15
xlrd>=1.0.0
schedule==0.6.0
Flask-HTTPAuth>=4.1.0
boto3==1.14.58
fsspec==0.8.2
pandas-profiling==2.9.0
在配置文件中安装kiwisolver依赖项时出错:
Collecting kiwisolver>=1.0.1
Downloading kiwisolver-1.2.0.tar.gz (52 kB)
ERROR: Command errored out with exit status 1:
command: /ddc/venv/bin/python -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-rwhpliwg/kiwisolver/setup.py'"'"'; __file__='"'"'/t
mp/pip-install-rwhpliwg/kiwisolver/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close
();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /tmp/pip-pip-egg-info-xjoogb9h
cwd: /tmp/pip-install-rwhpliwg/kiwisolver/
Complete output (44 lines):
WARNING: The wheel package is not available.
ERROR: Command errored out with exit status 1:
command: /ddc/venv/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-wheel-fjwbxpuf/cppy/setup.py'"'"'; __file__='"'"'/tmp/
pip-wheel-fjwbxpuf/cppy/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(com
pile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d /tmp/pip-wheel-pyjyn3n5
cwd: /tmp/pip-wheel-fjwbxpuf/cppy/
Complete output (6 lines):
usage: setup.py [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...]
or: setup.py --help [cmd1 cmd2 ...]
or: setup.py --help-commands
or: setup.py cmd --help
error: invalid command 'bdist_wheel'
----------------------------------------
ERROR: Failed building wheel for cppy
ERROR: Failed to build one or more wheels
Traceback (most recent call last):
File "/ddc/venv/lib/python3.8/site-packages/setuptools/installer.py", line 128, in fetch_build_egg
subprocess.check_call(cmd)
File "/usr/local/lib/python3.8/subprocess.py", line 364, in check_call
raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['/ddc/venv/bin/python', '-m', 'pip', '--disable-pip-version-check', 'wheel', '--no-deps', '-w', '/tmp/tmpnx5vz9py',
'--quiet', 'cppy>=1.1.0']' returned non-zero exit status 1.
您的环境无权访问
wheel
的安装。您应该能够通过添加以下行来解决此问题:RUN pip install wheel
在您尝试安装需求文件之前,请访问dockerfile
编辑:我错过了这里正在使用的虚拟环境。我认为在这种情况下使用虚拟环境是不必要的,除非OP使用他们的docker实例并行运行多个python应用程序。使用此模式有一些情况,但这里的情况似乎并非如此。因此,我的建议是完全取消
venv
,只需在docker实例python安装中安装所有依赖项,这将把每个venv/bin/pip
调用转换为一个简单的pip
调用您在虚拟环境中混合调用“系统”
pip
/python
和副本由于Docker映像已经位于与任何特定主机系统的Python安装分离的隔离环境中,因此通常在映像内将东西安装到“系统”Python中,而根本不使用虚拟环境。删除创建虚拟环境的行,只使用
pip
或python
覆盖venv/bin/...
备选方案相关问题 更多 >
编程相关推荐