Docker:从源代码构建psycopg2需要pg_config

时间:2019-12-02 10:06:55

标签: python postgresql docker

我目前正在寻求借助Lua Open Resty SSL和valian/docker-nginx-auto-ssl图像(见参考文献:https://github.com/Valian/docker-nginx-auto-ssl)来构建一个现成的SSL Django应用程序。

我想将上述项目中的Dockerfile与我的一个合并,并且在我的requirements.txt文件中安装pythonDependecy遇到了麻烦:

psycopg2-binary==2.8.4

在valian Dockerfile中指定的基本操作系统为Alpine,因此操作系统级别的依赖项来自apk。 (FROM openresty/openresty:alpine-fat

我收到的具体错误是:

Collecting psycopg2-binary==2.8.2
  Downloading https://files.pythonhosted.org/packages/dc/93/bb5655730913b88f9068c6b596177d1df83be0d476671199e17b06ea8436/psycopg2-binary-2.8.2.tar.gz (369kB)
    ERROR: Command errored out with exit status 1:
     command: /usr/local/lib/pyenv/versions/3.8.0/bin/python3.8 -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-6t5fbphg/psycopg2-binary/setup.py'"'"'; __file__='"'"'/tmp/pip-install-6t5fbphg/psycopg2-binary/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-install-6t5fbphg/psycopg2-binary/pip-egg-info
         cwd: /tmp/pip-install-6t5fbphg/psycopg2-binary/
    Complete output (23 lines):
    running egg_info
    creating /tmp/pip-install-6t5fbphg/psycopg2-binary/pip-egg-info/psycopg2_binary.egg-info
    writing /tmp/pip-install-6t5fbphg/psycopg2-binary/pip-egg-info/psycopg2_binary.egg-info/PKG-INFO
    writing dependency_links to /tmp/pip-install-6t5fbphg/psycopg2-binary/pip-egg-info/psycopg2_binary.egg-info/dependency_links.txt
    writing top-level names to /tmp/pip-install-6t5fbphg/psycopg2-binary/pip-egg-info/psycopg2_binary.egg-info/top_level.txt
    writing manifest file '/tmp/pip-install-6t5fbphg/psycopg2-binary/pip-egg-info/psycopg2_binary.egg-info/SOURCES.txt'

    Error: pg_config executable not found.

    pg_config is required to build psycopg2 from source.  Please add the directory
    containing pg_config to the $PATH or specify the full executable path with the
    option:

        python setup.py build_ext --pg-config /path/to/pg_config build ...

    or with the pg_config option in 'setup.cfg'.

    If you prefer to avoid building psycopg2 from source, please install the PyPI
    'psycopg2-binary' package instead.

    For further information please check the 'doc/src/install.rst' file (also at
    <http://initd.org/psycopg/docs/install.html>).

    ----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
ERROR: Service 'web' failed to build: The command '/bin/sh -c pip install -r requirements.txt' returned a non-zero code: 1

如果我使用psycopg2==2.8.4,也会发生这种情况。

所以,我想我需要怎么做才能为容器提供pg_config可执行文件?这是apk add postgresql附带的东西吗?

相关问题pg_config executable not found

0 个答案:

没有答案