【问题标题】:google buildpack psycopg2-binary Error: pg_config executable not foundgoogle buildpack psycopg2-binary 错误:找不到 pg_config 可执行文件
【发布时间】:2021-01-31 22:54:31
【问题描述】:

这是我的 requirements.txt psycopg2-binary==2.8.3 # via -r requirements/base.in

我在 docker 镜像中构建。我的印象是,如果我安装 psycopg2-binary vs psycopg2 我不应该安装额外的 postgresql 开发库。 我错了吗?

pack build --builder=gcr.io/buildpacks/builder:v1 test-python

Collecting psycopg2-binary==2.8.3
  Downloading psycopg2-binary-2.8.3.tar.gz (378 kB)
    ERROR: Command errored out with exit status 1:
     command: /layers/google.python.runtime/python/bin/python3 -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-z7z_l56l/psycopg2-binary_ddfc5ed05bb44cf4b7e2f14d634bd6ae/setup.py'"'"'; __file__='"'"'/tmp/pip-install-z7z_l56l/psycopg2-binary_ddfc5ed05bb44cf4b7e2f14d634bd6ae/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-vsc_2hlv
         cwd: /tmp/pip-install-z7z_l56l/psycopg2-binary_ddfc5ed05bb44cf4b7e2f14d634bd6ae/
    Complete output (23 lines):
    running egg_info
    creating /tmp/pip-pip-egg-info-vsc_2hlv/psycopg2_binary.egg-info
    writing /tmp/pip-pip-egg-info-vsc_2hlv/psycopg2_binary.egg-info/PKG-INFO
    writing dependency_links to /tmp/pip-pip-egg-info-vsc_2hlv/psycopg2_binary.egg-info/dependency_links.txt
    writing top-level names to /tmp/pip-pip-egg-info-vsc_2hlv/psycopg2_binary.egg-info/top_level.txt
    writing manifest file '/tmp/pip-pip-egg-info-vsc_2hlv/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>).

【问题讨论】:

    标签: python-3.x docker psycopg2 buildpack


    【解决方案1】:

    不,你没有错;我今天遇到了同样的问题,经过一番谷歌搜索后,我发现了这个(已解决的)github问题:https://github.com/psycopg/psycopg2/issues/699#

    那里的 cmets (https://github.com/psycopg/psycopg2/issues/699#issuecomment-377188700) 表明问题的一个可能原因是使用过时的 pip 版本。

    我使用的是 18.x 版本,升级后(python -m pip install -U pip,这让我获得了 pip 21.1.3),即使我没有任何 postgres,psycopg2-binary 的安装也成功完成(如预期的那样)已安装开发库。

    【讨论】:

      猜你喜欢
      • 2023-04-09
      • 1970-01-01
      • 2020-05-20
      • 2017-06-04
      • 2018-03-24
      • 2012-07-22
      相关资源
      最近更新 更多