pg_config executable not found

后端 未结 30 2146
渐次进展
渐次进展 2020-11-22 15:42

I am having trouble installing psycopg2. I get the following error when I try to pip install psycopg2:

Error: pg_config executable not found.

P         


        
相关标签:
30条回答
  • 2020-11-22 16:24

    To those on macOS Catalina using the zsh shell who have also installed the postgres app:

    Open your ~/.zshrc file, and add the following line:

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

    Then close all your terminals, reopen them, and you'll have resolved your problem.

    If you don't want to close your terminals, simply enter source ~/.zshrc in whatever terminal you'd like to keep working on.

    0 讨论(0)
  • 2020-11-22 16:25

    You need to upgrade your pip before installing psycopg2. Use this command

    pip install --upgrade pip
    
    0 讨论(0)
  • 2020-11-22 16:26

    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

    Source

    0 讨论(0)
  • 2020-11-22 16:28

    Try to add it to PATH:

    PATH=$PATH:/usr/pgsql-9.1/bin/ ./pip install psycopg2
    
    0 讨论(0)
  • 2020-11-22 16:28

    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.

    0 讨论(0)
  • 2020-11-22 16:29

    On Linux Mint sudo apt-get install libpq-dev worked for me.

    0 讨论(0)
提交回复
热议问题