Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pgcli has problem on M1 macOS Big Sur #1311

Closed
stardiviner opened this issue Jan 23, 2022 · 3 comments
Closed

pgcli has problem on M1 macOS Big Sur #1311

stardiviner opened this issue Jan 23, 2022 · 3 comments

Comments

@stardiviner
Copy link

stardiviner commented Jan 23, 2022

Description

When I pgcli -U <username> connect to local PostgreSQL server on M1 macOS system. I got error:

❯ pgcli -U stardiviner
Traceback (most recent call last):
  File "/Users/stardiviner/opt/anaconda3/bin/pgcli", line 5, in <module>
    from pgcli.main import cli
  File "/Users/stardiviner/opt/anaconda3/lib/python3.8/site-packages/pgcli/main.py", line 6, in <module>
    from pgspecial.namedqueries import NamedQueries
  File "/Users/stardiviner/opt/anaconda3/lib/python3.8/site-packages/pgspecial/__init__.py", line 13, in <module>
    from . import iocommands
  File "/Users/stardiviner/opt/anaconda3/lib/python3.8/site-packages/pgspecial/iocommands.py", line 11, in <module>
    import psycopg2
  File "/Users/stardiviner/opt/anaconda3/lib/python3.8/site-packages/psycopg2/__init__.py", line 51, in <module>
    from psycopg2._psycopg import (                     # noqa
ImportError: dlopen(/Users/stardiviner/opt/anaconda3/lib/python3.8/site-packages/psycopg2/_psycopg.cpython-38-darwin.so, 0x0002): symbol not found in flat namespace '_PQbackendPID'

Your environment

  • System: M1 macOS Big Sur 12.1
  • pgcli version: 3.3.1
pip freeze | grep pgcli
pgcli==3.3.1
@j-bennet
Copy link
Contributor

Yes, it looks like psycopg2 has this problem with M1 macbooks. There are a few threads in psycopg repo, it looks like this solution worked for some:

psycopg/psycopg2#1216 (comment)

Please try this and see if it helps.

@stardiviner
Copy link
Author

stardiviner commented Mar 10, 2022

After tried your linked solution, it still does not work.

  brew reinstall libpq --build-from-source
  export LDFLAGS="-L/opt/homebrew/opt/libpq/lib"
  pip install -U psycopg2 --no-cache-dir

image

@stardiviner
Copy link
Author

I tried Anaconda conda-forge channel. It works now.
Solution: conda install psycopg2 -c conda-forge.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants