Nice programing

pg_config 경로를 찾는 방법

nicepro 2020. 12. 2. 21:56
반응형

pg_config 경로를 찾는 방법


여기에서 초보자를 완료하고 ProstgreSQL과 함께 작동하도록 Django를 설정합니다.

저는 mac osx 10.6.8을 사용하고 있습니다. PostgreSQL 9.3도 설치했습니다.

pip install psycopg2터미널에서 실행할 때 다음 오류가 발생합니다.

Downloading/unpacking psycopg2
  Downloading psycopg2-2.5.2.tar.gz (685kB): 685kB downloaded
  Running setup.py (path:/private/var/folders/A9/A99cs6x0FNusPejCVkYNTE+++TI/-Tmp-/pip_build_bengorman/psycopg2/setup.py) egg_info for package psycopg2

    Error: pg_config executable not found.

    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'.
    Complete output from command python setup.py egg_info:
    running egg_info

creating pip-egg-info/psycopg2.egg-info

writing pip-egg-info/psycopg2.egg-info/PKG-INFO

writing top-level names to pip-egg-info/psycopg2.egg-info/top_level.txt

writing dependency_links to pip-egg-info/psycopg2.egg-info/dependency_links.txt

writing manifest file 'pip-egg-info/psycopg2.egg-info/SOURCES.txt'

warning: manifest_maker: standard file '-c' not found



Error: pg_config executable not found.



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'.

나는이
how-to-install-psycopg2-with-pip-on-python pg-config-executable-not-found 에 대한 많은 게시물을 보았습니다.

하지만 pg_config를 포함하는 bin 폴더 위치를 찾는 방법에 대한 단서가 없습니다. 이 길을 찾기위한 팁이 있습니까?


Postgres.app을 사용하는 것이 좋습니다. ( http://postgresapp.com ) 이렇게하면 Mac에서 Postgres를 쉽게 켜고 끌 수 있습니다. 그런 .profile다음 다음을 추가하여 Postgres 경로를 파일에 추가합니다.

PATH="/Applications/Postgres.app/Contents/Versions/latest/bin:$PATH"

경로에 Postgres를 추가 한 후에 만 psycopg2가상 환경 (pip 사용) 또는 글로벌 사이트 패키지 에 설치 시도 할 수 있습니다 .


sudo find / -name "pg_config" -print

대답은 내 구성의 /Library/PostgreSQL/9.1/bin/pg_config입니다 (MAC Maverick).


Postgres.app이 최근에 업데이트되었습니다. 이제 모든 바이너리를 "Versions"폴더에 저장합니다.

PATH="/Applications/Postgres.app/Contents/Versions/9.4/bin:$PATH"

여기서 9.4 – PostgreSQL 버전.


Homebrew 설치

/usr/bin/ruby -e "$(curl -fsSL https://raw.github.com/gist/323731)"

그리고 postgresql 설치

brew install postgresql

이 멋진 출력을주었습니다.

checking for pg_config... yes

아 yeahhhhh


MacOS X 10.11에 현재 PostgreSQL 앱을 설치하면 여기에 pg_config 파일이 /Library/PostgreSQL/9.5/bin/pg_config있습니다.

그런 다음 터미널에서 :

    $ export PG_HOME=/Library/PostgreSQL/9.5
    $ export PATH=$PATH:$PG_HOME/bin

이렇게하면 사용중인 터미널의 .profile에 경로가 저장됩니다.

환경 (을 사용한다고 가정 virtualenv)에서 psycopg2를 설치합니다.

    $ pip install psycopg2

이전에 다운로드했는지 확인해야합니다.

    Collecting psycopg2
      Using cached psycopg2-2.6.1.tar.gz
    Installing collected packages: psycopg2
      Running setup.py install for psycopg2 ... done
    Successfully installed psycopg2-2.6.1

To summarize -- PostgreSQL installs its files (including its binary or executable files) in different locations, depending on the version number and the installation method.

Some of the possibilities:

/usr/local/bin/
/Library/PostgreSQL/9.2/bin/
/Applications/Postgres93.app/Contents/MacOS/bin/
/Applications/Postgres.app/Contents/Versions/9.3/bin/

No wonder people get confused!

Also, if your $PATH environment variable includes a path to the directory that includes an executable file (to confirm this, use echo $PATH on the command line) then you can run which pg_config, which psql, etc. to find out where the file is located.


I had exactly the same error, but I installed postgreSQL through brew and re-run the original command and it worked perfectly :

brew install postgresql


You can find the pg_config directory using its namesake:

$ pg_config --bindir
/usr/lib/postgresql/9.1/bin
$ 

Tested on Mac and Debian. The only wrinkle is that I can't see how to find the bindir for different versions of postgres installed on the same machine. It's fairly easy to guess though! :-)

Note: I updated my pg_config to 9.5 on Debian with:

sudo apt-get install postgresql-server-dev-9.5

check /Library/PostgreSQL/9.3/bin and you should find pg_config

I.E. /Library/PostgreSQL/<version_num>/

ps: you can do the following if you deem it necessary for your pg needs -

create a .profile in your ~ directory

export PG_HOME=/Library/PostgreSQL/9.3
export PATH=$PATH:$PG_HOME/bin

You can now use psql or postgres commands from the terminal, and install psycopg2 or any other dependency without issues, plus you can always just ls $PG_HOME/bin when you feel like peeking at your pg_dir.


I used :

export PATH=$PATH:/Library/PostgreSQL/9.6/bin

pip install psycopg2

Have same issue on mac, you probably need to

brew install postgresql

then you can run

pip install psycopg2

The brew will fix PATH issue for you

this solution works for me at least.


This is how to simply get the path of pg_config

$ which pg_config                 // prints the directory location 
/usr/bin/pg_config

참고URL : https://stackoverflow.com/questions/21079820/how-to-find-pg-config-path

반응형