1

执行 'docker build -t $name 。以下问题失败。它显示'mariadb_config not found',但我已经在这个 suse15 linux 服务器上安装了 mariadb。

Collecting mariadb==1.0.4
  Downloading mariadb-1.0.4.tar.gz (66 kB)
    ERROR: Command errored out with exit status 1:
     command: /usr/local/bin/python -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-lxx0giq5/mariadb/setup.py'"'"'; __file__='"'"'/tmp/pip-install-lxx0giq5/mariadb/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-hicsuruq
         cwd: /tmp/pip-install-lxx0giq5/mariadb/
    Complete output (17 lines):
    /bin/sh: 1: mariadb_config: not found
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/tmp/pip-install-lxx0giq5/mariadb/setup.py", line 26, in <module>
        cfg = get_config(options)
      File "/tmp/pip-install-lxx0giq5/mariadb/mariadb_posix.py", line 59, in get_config
        cc_version = mariadb_config(config_prg, "cc_version")
      File "/tmp/pip-install-lxx0giq5/mariadb/mariadb_posix.py", line 29, in mariadb_config
        "mariadb_config not found.\n\nPlease make sure, that MariaDB Connector/C is installed on your system.\n"
    OSError: mariadb_config not found.

    Please make sure, that MariaDB Connector/C is installed on your system.
    Either set the environment variable MARIADB_CONFIG or edit the configuration
    file 'site.cfg' and set the 'mariadb_config option, which should point
    to the mariadb_config utility.
    The MariaDB Download website at <https://downloads.mariadb.com/Connectors/c/>
    provides latest stable releease of Connector/C.
    ----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
The command '/bin/sh -c pip3 install -r requirements.txt' returned a non-zero code: 1

相关的Dockerfile内容如下。

FROM python:3.6.5

WORKDIR /slic-scripts

COPY requirements.txt .

RUN pip install --upgrade pip

RUN pip3 install -r requirements.txt

COPY . .

CMD ["python3", "/slic-scripts/run_cmd.sh"]
4

3 回答 3

2

在运行pip3 install. 将它安装在主机上并没有帮助。

于 2020-10-25T08:00:01.297 回答
1

正如@Jonathan Jacobson 所写,您需要在 Docker 映像中安装 MariaDB 连接器,然后再继续pip install.

由于python:3.6.5基于 debian 拉伸,因此提供的连接器是 2.3.2,该mariadb模块不支持(如先决条件中所述)。要解决此问题,您可能需要切换到不同的图像(例如 3.6-buster)。

这是一个工作测试:

FROM python:3.6-buster

RUN apt-get update \
    && apt-get -yy install libmariadb-dev

WORKDIR /slic-scripts
COPY requirements.txt .
RUN pip install --upgrade pip
RUN pip3 install -r requirements.txt
COPY . .

CMD ["python3", "/slic-scripts/run_cmd.sh"]
于 2020-10-25T09:35:58.870 回答
0

使用以下命令安装 MariaDB Connector/C,这是一个依赖项。

sudo apt-get install libmariadb3 libmariadb-dev

RUN pip3 install -r requirements.txt

于 2020-10-25T10:07:39.143 回答