繁体   English   中英

[Dockerfile中的Python],如何找出“ Requirements.txt”文件中软件包的正确顺序?

[英][Python in Dockerfile], how can I find out what is the correct order of packages in the “Requirements.txt” file?

嗨,我正在为Python构建一个简单的Docker映像,我正在努力找出Requirements.txt中软件包的正确顺序。

当它在Dockerfile中撞到beow行时,它在执行中间失败

RUN  pip install  -r requirements.txt

我将输出放在下面作为错误。

有谁知道如何找出来?

Docker文件

FROM python:3.7-buster

ENV ACCEPT_EULA=Y

COPY . /app
WORKDIR /app

# Microsoft SQL Server Prerequisites (installing ODBC Drivervin Linux))
RUN apt-get update \
    && curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add - \
    && curl https://packages.microsoft.com/config/debian/9/prod.list \
        > /etc/apt/sources.list.d/mssql-release.list \
    && apt-get install -y --no-install-recommends \
        locales \
        apt-transport-https \
    && echo "en_US.UTF-8 UTF-8" > /etc/locale.gen \
    && locale-gen \
    && apt-get update \
    && apt-get -y --no-install-recommends install \
        unixodbc-dev \
        msodbcsql17 


RUN pip install --upgrade pip   

RUN  pip install   -r requirements.txt


EXPOSE 5000

requirements.txt

flask==1.1.1
SQLAlchemy==1.1.15
pyodbc==4.0.21
simplejson==3.13.2
matplotlib==2.1.0
scikit-learn==0.20.2
surprise==0.1
scikit-learn==0.20.2
O365==1.1.5
pandas==0.23.4
numpy==1.14.0
scipy==1.0.0

错误

 Building wheel for pyodbc (setup.py): started
  Building wheel for pyodbc (setup.py): finished with status 'error'
  ERROR: Command errored out with exit status 1:
   command: /usr/local/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-mubf1uaz/pyodbc/setup.py'"'"'; __file__='"'"'/tmp/pip-install-mubf1uaz/pyodbc/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d /tmp/pip-wheel-v2ateps5 --python-tag cp37
       cwd: /tmp/pip-install-mubf1uaz/pyodbc/
  Complete output (55 lines):
  running bdist_wheel
  running build
  running build_ext
  building 'pyodbc' extension
  creating build
  creating build/temp.linux-x86_64-3.7
  creating build/temp.linux-x86_64-3.7/src
  gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -DPYODBC_VERSION=4.0.21 -I/usr/local/include/python3.7m -c src/buffer.cpp -o build/temp.linux-x86_64-3.7/src/buffer.o -Wno-write-strings
  gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -DPYODBC_VERSION=4.0.21 -I/usr/local/include/python3.7m -c src/errors.cpp -o build/temp.linux-x86_64-3.7/src/errors.o -Wno-write-strings
  src/errors.cpp: In function ‘PyObject* GetErrorFromHandle(Connection*, const char*, HDBC, HSTMT)’:
  src/errors.cpp:332:44: warning: ‘Py_ssize_t PyUnicode_GetSize(PyObject*)’ is deprecated [-Wdeprecated-declarations]
       if (!msg || PyUnicode_GetSize(msg.Get()) == 0)
                                              ^
  In file included from /usr/local/include/python3.7m/Python.h:99,
                   from src/pyodbc.h:45,
                   from src/errors.cpp:2:
  /usr/local/include/python3.7m/unicodeobject.h:793:24: note: declared here
   PyAPI_FUNC(Py_ssize_t) PyUnicode_GetSize(
                          ^~~~~~~~~~~~~~~~~
  src/errors.cpp:332:44: warning: ‘Py_ssize_t PyUnicode_GetSize(PyObject*)’ is deprecated [-Wdeprecated-declarations]
       if (!msg || PyUnicode_GetSize(msg.Get()) == 0)
                                              ^
  In file included from /usr/local/include/python3.7m/Python.h:99,
                   from src/pyodbc.h:45,
                   from src/errors.cpp:2:
  /usr/local/include/python3.7m/unicodeobject.h:793:24: note: declared here
   PyAPI_FUNC(Py_ssize_t) PyUnicode_GetSize(
                          ^~~~~~~~~~~~~~~~~
  gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -DPYODBC_VERSION=4.0.21 -I/usr/local/include/python3.7m -c src/cnxninfo.cpp -o build/temp.linux-x86_64-3.7/src/cnxninfo.o -Wno-write-strings
  src/cnxninfo.cpp: In function ‘PyObject* GetHash(PyObject*)’:
  src/cnxninfo.cpp:45:88: warning: ‘PyObject* PyUnicode_EncodeUTF8(const Py_UNICODE*, Py_ssize_t, const char*)’ is deprecated [-Wdeprecated-declarations]
       Object bytes(PyUnicode_EncodeUTF8(PyUnicode_AS_UNICODE(p), PyUnicode_GET_SIZE(p), 0));
                                                                                          ^
  In file included from /usr/local/include/python3.7m/Python.h:99,
                   from src/pyodbc.h:45,
                   from src/cnxninfo.cpp:7:
  /usr/local/include/python3.7m/unicodeobject.h:1320:23: note: declared here
   PyAPI_FUNC(PyObject*) PyUnicode_EncodeUTF8(
                         ^~~~~~~~~~~~~~~~~~~~
  src/cnxninfo.cpp:45:88: warning: ‘PyObject* PyUnicode_EncodeUTF8(const Py_UNICODE*, Py_ssize_t, const char*)’ is deprecated [-Wdeprecated-declarations]
       Object bytes(PyUnicode_EncodeUTF8(PyUnicode_AS_UNICODE(p), PyUnicode_GET_SIZE(p), 0));
                                                                                          ^
  In file included from /usr/local/include/python3.7m/Python.h:99,
                   from src/pyodbc.h:45,
                   from src/cnxninfo.cpp:7:
  /usr/local/include/python3.7m/unicodeobject.h:1320:23: note: declared here
   PyAPI_FUNC(PyObject*) PyUnicode_EncodeUTF8(
                         ^~~~~~~~~~~~~~~~~~~~
  gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -DPYODBC_VERSION=4.0.21 -I/usr/local/include/python3.7m -c src/pyodbcdbg.cpp -o build/temp.linux-x86_64-3.7/src/pyodbcdbg.o -Wno-write-strings
  gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -DPYODBC_VERSION=4.0.21 -I/usr/local/include/python3.7m -c src/getdata.cpp -o build/temp.linux-x86_64-3.7/src/getdata.o -Wno-write-strings
  src/getdata.cpp: In function ‘PyObject* GetDataDecimal(Cursor*, Py_ssize_t)’:
  src/getdata.cpp:405:38: error: invalid conversion from ‘const char*’ to ‘char*’ [-fpermissive]
           pch = PyUnicode_AsUTF8AndSize(result, &cch);
                 ~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~
  error: command 'gcc' failed with exit status 1
  ----------------------------------------
  ERROR: Failed building wheel for pyodbc
  Running setup.py clean for pyodbc

正如@LinPy所说,要点子是按顺序提取需求文件的,所以您只需要根据它们自己的依赖关系对包进行重新排序。

对于第二个问题,您是否检查了pyodbc必需的组件: https : //github.com/mkleehammer/pyodbc/wiki/Install特别是它们提到了unixodbc-dev软件包。

由于您在编码方面遇到问题,因此还应仔细检查您的语言环境。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM