pg_config 실행 파일을 찾을 수 없습니다.
psycopg2를 설치하는 데 문제가 있습니다. 시도 할 때 다음 오류가 발생합니다 pip install 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'.
----------------------------------------
Command python setup.py egg_info failed with error code 1 in /tmp/pip-build/psycopg2
그러나 문제는 pg_config
실제로 내입니다 PATH
. 문제없이 실행됩니다.
$ which pg_config
/usr/pgsql-9.1/bin/pg_config
pg_config 경로를 setup.cfg
파일에 추가 하고 웹 사이트 ( http://initd.org/psycopg/ ) 에서 다운로드 한 소스 파일을 사용하여 빌드 하려고했는데 다음과 같은 오류 메시지가 표시됩니다!
Error: Unable to find 'pg_config' file in '/usr/pgsql-9.1/bin/'
하지만 실제로 거기에 !!!
나는 이러한 오류에 당황합니다. 누구든지 제발 도와 줄 수 있습니까?
그건 그렇고, 나는 sudo
모든 명령. 또한 RHEL 5.5를 사용하고 있습니다.
pg_config
에 있습니다 postgresql-devel
( libpq-dev
Debian / Ubuntu, libpq-devel
Cygwin / Babun).
Mac OS X에서는 homebrew 패키지 관리자를 사용하여 해결했습니다.
brew install postgresql
python-dev를 설치 했습니까? 이미 가지고 있다면 libpq-dev도 설치하십시오.
sudo apt-get install libpq-dev python-dev
기사에서 : virtualenv에서 psycopg2를 설치하는 방법
OSX에서도 마찬가지입니다. http://postgresapp.com/ 에서 Postgress.app을 설치 했지만 동일한 문제가 발생했습니다.
pg_config
해당 앱의 콘텐츠를 발견 하고 $PATH
.
에 있었다 /Applications/Postgres.app/Contents/Versions/latest/bin
. 그래서 이것은 효과가 export PATH="/Applications/Postgres.app/Contents/Versions/latest/bin:$PATH"
있습니다.
알파인에서 포함하는 라이브러리 pg_config
는 postgresql-dev
. 설치하려면 다음을 실행하십시오.
apk add postgresql-dev
apt-get build-dep python-psycopg2
sudo apt-get install libpq-dev
Ubuntu 15.4에서 나를 위해 작동합니다.
Ubuntu의 Postgres에서 사용되는 Python 요구 사항을 추가해야합니다. 운영:
sudo apt-get install libpq-dev python-dev
요약하자면 저도 똑같은 문제에 직면했습니다. 많은 stackoverflow 게시물과 온라인 블로그를 읽은 후 저에게 도움이 된 최종 솔루션은 다음과 같습니다.
1) PostgreSQL(development or any stable version) should be installed before installing psycopg2.
2) The pg_config file (this file normally resides in the bin folder of the PostgreSQL installation folder) PATH had to be explicitly setup before installing psycopg2. In my case, the installation PATH for PostgreSQL is:
/opt/local/lib/postgresql91/
so in order to explicitly set the PATH of pg_config file, I entered following command in my terminal:
PATH=$PATH:/opt/local/lib/postgresql91/bin/
This command ensures that when you try to pip install psycopg2, it would find the PATH to pg_config automatically this time.
I have also posted a full error with trace and its solution on my blog which you may want to refer. Its for Mac OS X but the pg_config PATH problem is generic and applicable to Linux also.
This is what worked for me on CentOS, first install:
sudo yum install postgresql postgresql-devel python-devel
On Ubuntu just use the equivilent apt-get packages.
sudo apt-get install postgresql postgresql-dev python-dev
And now include the path to your postgresql binary dir with you pip install, this should work for either Debain or RHEL based Linux:
sudo PATH=$PATH:/usr/pgsql-9.3/bin/ pip install psycopg2
Make sure to include the correct path. Thats all :)
On Linux Mint sudo apt-get install libpq-dev
worked for me.
UPDATE /etc/yum.repos.d/CentOS-Base.repo, [base] and [updates] sections
ADD exclude=postgresql*
curl -O http://yum.postgresql.org/9.1/redhat/rhel-6-i386/pgdg-centos91-9.1-4.noarch.rpmr
rpm -ivh pgdg-centos91-9.1-4.noarch.rpm
yum install postgresql
yum install postgresql-devel
PATH=$PATH:/usr/pgsql-9.1/bin/
pip install psycopg2
For those running OS X, this solution worked for me:
1) Install Postgres.app:
http://www.postgresql.org/download/macosx/
2) Then open the Terminal and run this command, replacing where it says {{version}} with the Postgres version number:
export PATH=$PATH:/Applications/Postgres.app/Contents/Versions/{{version}}/bin
e.g.
export PATH=$PATH:/Applications/Postgres.app/Contents/Versions/9.4/bin
Try to add it to PATH:
PATH=$PATH:/usr/pgsql-9.1/bin/ ./pip install psycopg2
Ali's solution worked for me but I was having trouble finding the bin folder location. A quick way to find the path on Mac OS X is to open psql (there's a quick link in the top menu bar). This will open a separate terminal window and on the second line the path of your Postgres installation will appear like so:
My-MacBook-Pro:~ Me$ /Applications/Postgres93.app/Contents/MacOS/bin/psql ; exit;
Your pg_config file is in that bin folder. Therefore, before installing psycopg2 set the path of the pg_config file:
PATH=$PATH:/Applications/Postgres93.app/Contents/MacOS/bin/
or for newer version:
PATH=$PATH:/Applications/Postgres.app/Contents/Versions/9.3/bin
Then install psycopg2.
You need to upgrade your pip before installing psycopg2. Use this command
pip install --upgrade pip
Just solved the problem in Cent OS 7 by:
export PATH=$PATH:/usr/pgsql-9.5/bin
make sure your PostgreSql version matches the right version above.
On Windows, You may want to install the Windows port of Psycopg, which is recommended in psycopg's documentation.
On Mac OS X and If you are using Postgres App (http://postgresapp.com/):
export PATH=$PATH:/Applications/Postgres.app/Contents/Versions/latest/bin
No need to specify version of Postgres in this command. It will be always pointed to latest.
and do
pip install psycopg2
P.S: If Changes doesn't reflect you may need to restart the Terminal/Command prompt
sudo yum install postgresql-devel (centos6X)
pip install psycopg2==2.5.2
Here, for OS X completeness: if you install PostgreSQL from MacPorts, pg_config will be in /opt/local/lib/postgresql94/bin/pg_config
.
When you installed MacPorts, it already added /opt/local/bin
to your PATH.
So, this will fix the problem: $ sudo ln -s /opt/local/lib/postgresql94/bin/pg_config /opt/local/bin/pg_config
Now pip install psycopg2
will be able to run pg_config
without issues.
Installing python-psycopg2
solved it for me on Arch Linux:
pacman -S python-psycopg2
On MacOS, the simplest will is to symlink the correct binary, which is inside the Postgres package.
sudo ln -s /Applications/Postgres.app/Contents/Versions/latest/bin/pg_config /usr/local/bin/pg_config
This is fairly harmless, and all the applications will be able to use it system wide, if required.
I'm going to leave this here for the next unfortunate soul who can't get around this problem despite all the provided solutions. Simply use sudo pip3 install psycopg2-binary
for CentOS/RedHat make sure that /etc/alternatives/pgsql-pg_config
is a non-broken symlink
I am pretty sure you've experienced the same "problem" i did, therefore I'll offer you the extremely easy solution...
In your case, the actual path that you need to add to $PATH (or as a command param) is:
/usr/pgsql-9.1/bin/pg_config
not
/usr/pgsql-9.1/bin
E.g. if you run the python setup.py script afterwards, you would run it like this:
python setup.py build_ext --pg-config /usr/pgsql-9.1/bin/pg_config build
Probably too late, but still the easiest solution.
LATER EDIT:
Under further test I found out that if you initially add the path to pg_config in the form
/usr/pgsql-9.1/bin
(without /pg_config after ...../bin) and run the pip install command it will work.
However, if you then decide to follow the indication to run python setup.py, you will have to specify the path with /pg_config after ...../bin, i.e.
python setup.py build_ext --pg-config /usr/pgsql-9.1/bin/pg_config build
On Gentoo You have to execute the following
# Install postgresql client libraries
sudo emerge postgresql-base
This is how I managed to install psycopg2
$ wget http://initd.org/psycopg/tarballs/PSYCOPG-2-5/psycopg2-2.5.3.tar.gz
$ tar -xzf psycopg2-2.5.3.tar.gz
$ cd psycopg2-2.5.3
$ pip install .
For anyone experiencing this issue working on a Django application and deploying to AWS, the method described in this tutorial worked for me: https://realpython.com/deploying-a-django-app-and-postgresql-to-aws-elastic-beanstalk/
Here is the author's explanation for when you get the following error:
Error: pg_config executable not found.
The problem is that we tried to install psycopy2 (the Postgres Python bindings), but we need the Postgres client drivers to be installed as well. Since they are not installed by default, we need to install them first.
eb will read custom .config files from a folder called “.ebextensions” at the root level of your project. These .config files allow you to install packages, run arbitrary commands and/or set environment variables. Files in the “.ebextensions” directory should conform to either JSON or YAML syntax and are executed in alphabetical order.
The first thing to do is install some packages so that our pip install command will complete successfully. To do this, let’s create a file called .ebextensions/01_packages.config:
packages:
yum:
git: []
postgresql93-devel: []
libjpeg-turbo-devel: []
EC2 instances run Amazon Linux, which is a Redhat flavor, so we can use yum to install the packages that we need. For now, we are just going to install three packages - git, the Postgres client, and libjpeg for Pillow.
I found that this page provided the best instructions for installing PostgreSQL on my mac and that the pip install command worked perfectly afterwards:
https://www.codefellows.org/blog/three-battle-tested-ways-to-install-postgresql
참고URL : https://stackoverflow.com/questions/11618898/pg-config-executable-not-found
'Nice programing' 카테고리의 다른 글
원시 유형은 무엇이며 왜 사용하지 않아야합니까? (0) | 2020.10.02 |
---|---|
SQL 조인 : where 절 대 on 절 (0) | 2020.10.02 |
iOS 8에서 작동하지 않는 위치 서비스 (0) | 2020.10.02 |
Cache-Control : max-age = 0과 no-cache의 차이점은 무엇입니까? (0) | 2020.10.02 |
Flexbox 항목 사이의 거리를 설정하는 더 나은 방법 (0) | 2020.10.02 |