Re: ImportError: symbol not found in flat namespace '_PQbackendPID' - Mailing list psycopg

From Daniele Varrazzo
Subject Re: ImportError: symbol not found in flat namespace '_PQbackendPID'
Date
Msg-id CA+mi_8Yqqfde-dPSWv0QxJXEzK91MT0eXq7t93M4RjjRpaf=xQ@mail.gmail.com
Whole thread Raw
In response to ImportError: symbol not found in flat namespace '_PQbackendPID'  (Gil Sousa <gilsousa@gmail.com>)
List psycopg
Hello,

On Tue, 6 Sept 2022 at 17:06, Gil Sousa <gilsousa@gmail.com> wrote:
>
> Hi all,
>
> I am trying to use psycopg2 for the very first time, though I am stumbling with an error when trying to import the
module:
>
> ✗ python3.9 radars_import.py
> Traceback (most recent call last):
>   File "/Users/gilsousa/Documents/git Projects/ReportGen/radars_import.py", line 2, in <module>
>     import psycopg2
>   File "/Users/gilsousa/Library/Python/3.9/lib/python/site-packages/psycopg2/__init__.py", line 51, in <module>
>     from psycopg2._psycopg import (                     # noqa
> ImportError:
dlopen(/Users/gilsousa/Library/Python/3.9/lib/python/site-packages/psycopg2/_psycopg.cpython-39-darwin.so,0x0002):
symbolnot found in flat namespace '_PQbackendPID' 
>
> I made sure that I have the packages installed, both psycopg2 and psycopg2-binary. I even tried to uninstall both and
justtry one at a time, also didn't work. 

You should install only one of them. If you are using an apple M1,
psycopg2-binary doesn't actually install a binary package and falls
back to building from source.

> How can I fix this problem?

I don't have a macOS but the problem has surfaced often, according to
google. It seems related to the wrong installation of the libpq, and
it doesn't help that a few days ago Homebrew has broken the libpq
installation <https://github.com/psycopg/psycopg2/issues/1492>.

See https://gist.github.com/peter-gy/0ebe072acb9065944ecb04d95a4c3096
for an example of someone fixing your problem.

Cheers

-- Daniele



psycopg by date:

Previous
From: Gil Sousa
Date:
Subject: ImportError: symbol not found in flat namespace '_PQbackendPID'
Next
From: Stefan Knecht
Date:
Subject: Puzzling situation with threads and psycopg2 on RDS