install Psycopg2 on mac osx 10.9.5

后端 未结 12 622
清酒与你
清酒与你 2020-11-27 04:42

I\'m trying to install Psycopg2 on my Mac-book. I still get the same error. I found a lot of same questions on Stack Overflow but no answer seems to work. I think it is outd

相关标签:
12条回答
  • 2020-11-27 05:16

    You don't seem to have postgres installed, check how to install postgresql in your system, one of the way is brew install postgresql (if you use homebrew- recommended) or download the postgres app from postgresapp.com, pg_config should come with postgres and psycopg2 is trying to find it.

    0 讨论(0)
  • 2020-11-27 05:20

    OSX doesn't include PostgreSQL anymore, so you need to install it in some way to build the binary part of psycopg2 module.

    I've used both brew and port. Installing any PostgreSQL version through one of them will enable you to build the module.

    If you install Postgres in other ways, you need to check that the executable pg_config in in your path.

    You can check for pg_config presence using the command

    which -a pg_config
    

    If you have Postgres installed and the aforementioned command doesn't return anything, you need to manually find the pg_config executable and put its containing directory in your PATH with:

    export PATH=/path/to/postgresql/bin/:$PATH
    

    Edit:

    If you already installed it through homebrew, but it is not in your path, you should check if the /usr/local/bin directory is present in your path and add it if missing

    If the directory is there, you can try to relink postgres with the following command

    brew unlink postgresql && brew link postgresql
    
    0 讨论(0)
  • 2020-11-27 05:23

    I ran pip install psycopg2-binary and it worked like charm

    More info about the binary package

    0 讨论(0)
  • 2020-11-27 05:23

    Even I was unable to install psycopg2 on MacOx 10.15.6.

    I tried pip install psycopg2-binary and it worked.

    0 讨论(0)
  • 2020-11-27 05:23

    I've had issues with this. What I did was make sure that Python was up to date with how I was pip installing. It required a "pip3" install.

    0 讨论(0)
  • 2020-11-27 05:25

    To install psycopg2 in mac, follow the below steps

    1. Goto Application folder
    2. Select Postgre.app
    3. Right click and "Show package contents"
    4. Select Content-->Versions-->{Version Number}-->bin
    5. Check the version number

    export PATH=$PATH:/Applications/Postgres.app/Contents/Versions/{Version Number}/bin/
    

    Example

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

    Then run the below

    pip3 install psycopg2
    

    This should fix your issue

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