https://pantsbuild.org/ logo
#general
Title
# general
b

bulky-evening-62934

04/22/2020, 6:15 PM
Hi all, I met some issues when using
psycopg
as a third party dependency, the error is,
Error: pg_config executable not found.
I actually have
pg_config
in the $PATH,
which pg_config
-->
/usr/local/bin/pg_config
, I’m wondering the issue is that pex subprosses don’t have it in its $PATH, am I missing some settings ? (one solution is using psycopg-binary, which is the pre built wheel, but the authors said not using it in production …)
h

hundreds-father-404

04/22/2020, 6:18 PM
What command are you trying to run with this?
b

bulky-evening-62934

04/22/2020, 6:18 PM
./pants binary
psycopg
is a third party dependency specified in BUILD
h

hundreds-father-404

04/22/2020, 6:21 PM
Hm, could you please post the full stack trace? We include
$PATH
by default in the subprocess. Precisely, we include whatever you specify in
--python-setup-interpreter-search-paths
. Maybe you removed
<PATH>
from it, given the prior thread?
b

bulky-evening-62934

04/22/2020, 6:26 PM
Copy code
ERROR: process 'Resolving psycopg2==2.8.5' failed with exit code 1.
stdout:

stderr:
    ERROR: Command errored out with exit status 1:
     command: /Users/yuhan/.pyenv/versions/3.7.5/bin/python3.7 -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/tmp/pip-download-voh40dac/psycopg2/setup.py'"'"'; __file__='"'"'/private/tmp/pip-download-voh40dac/psycopg2/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' --no-user-cfg egg_info --egg-base /private/tmp/pip-download-voh40dac/psycopg2/pip-egg-info
         cwd: /private/tmp/pip-download-voh40dac/psycopg2/
    Complete output (23 lines):
    running egg_info
    creating /private/tmp/pip-download-voh40dac/psycopg2/pip-egg-info/psycopg2.egg-info
    writing /private/tmp/pip-download-voh40dac/psycopg2/pip-egg-info/psycopg2.egg-info/PKG-INFO
    writing dependency_links to /private/tmp/pip-download-voh40dac/psycopg2/pip-egg-info/psycopg2.egg-info/dependency_links.txt
    writing top-level names to /private/tmp/pip-download-voh40dac/psycopg2/pip-egg-info/psycopg2.egg-info/top_level.txt
    writing manifest file '/private/tmp/pip-download-voh40dac/psycopg2/pip-egg-info/psycopg2.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
    <<https://www.psycopg.org/docs/install.html>>).
    
    ----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
pid: 3636 -> /Users/yuhan/.pyenv/versions/3.7.5/bin/python3.7 /private/var/folders/97/q6plwtfn2mqcqm_3ywcv8nhh0000gp/T/process-executiongCXkjm/pex_root/pip.pex/49a647f5ed9e81dc8f85560600c53fbb4dfc60f0 --disable-pip-version-check --isolated --no-python-version-warning -q --cache-dir /private/var/folders/97/q6plwtfn2mqcqm_3ywcv8nhh0000gp/T/process-executiongCXkjm/pex_root download --dest /tmp/tmp6x5l9hw9/resolved_dists/cp37-cp37m --index-url <https://pypi.org/simple/> psycopg2==2.8.5 raised Executing /Users/yuhan/.pyenv/versions/3.7.5/bin/python3.7 /private/var/folders/97/q6plwtfn2mqcqm_3ywcv8nhh0000gp/T/process-executiongCXkjm/pex_root/pip.pex/49a647f5ed9e81dc8f85560600c53fbb4dfc60f0 --disable-pip-version-check --isolated --no-python-version-warning -q --cache-dir /private/var/folders/97/q6plwtfn2mqcqm_3ywcv8nhh0000gp/T/process-executiongCXkjm/pex_root download --dest /tmp/tmp6x5l9hw9/resolved_dists/cp37-cp37m --index-url <https://pypi.org/simple/> psycopg2==2.8.5 failed with 1
@hundreds-father-404 from https://github.com/pantsbuild/pants/blob/3384a5c761232304cd8a8262709cdc21df204e59/src/python/pants/util/strutil.py#L65-L89, I think this code doesn’t successfully append $PATH, because
_PATH_=create_path_env_var(python_setup.interpreter_search_paths)
,
env
is default to None
it seems to be a bug ?
h

hundreds-father-404

04/22/2020, 6:33 PM
env
is none, but
new_entries
is specified to be whatever
python_setup.interpreter_search_paths
is. So long as
--python-setup-interpreter-search-paths
includes
<PATH>
, that will get passed to the Pex subprocess
b

bulky-evening-62934

04/22/2020, 6:35 PM
But I have
interpreter_search_paths = ["<PYENV>"]
, so I need to write something like ``interpreter_search_paths = ["<PYENV>", "$PATH"]`` ? (if my PR get passed ; ) )
h

hundreds-father-404

04/22/2020, 6:35 PM
Yes, exactly
But, you can already use
<PATH>
, that is a special value
👍 1
b

bulky-evening-62934

04/22/2020, 6:42 PM
that makes sense,
interpreter_search_paths = ["<PYENV>", "<PATH>"]
works perfectly,
👍 1
❤️ 1
h

hundreds-father-404

04/22/2020, 6:42 PM
wonderful 🙂
5 Views