Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oVicO-0007fy-Da for psycopg@arkaria.postgresql.org; Wed, 07 Sep 2022 00:08:36 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1oVicN-0000y8-Cz for psycopg@arkaria.postgresql.org; Wed, 07 Sep 2022 00:08:35 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oVicN-0000xz-40 for psycopg@lists.postgresql.org; Wed, 07 Sep 2022 00:08:35 +0000 Received: from mail-pl1-x634.google.com ([2607:f8b0:4864:20::634]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1oVicK-0002PD-Er for psycopg@lists.postgresql.org; Wed, 07 Sep 2022 00:08:34 +0000 Received: by mail-pl1-x634.google.com with SMTP id v5so12845398plo.9 for ; Tue, 06 Sep 2022 17:08:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date; bh=3NIhY/skgAS/vlt4TesSf/0z6IIzJyzrvHiwj911Fek=; b=iHLPBOf9FQnY7GSdYZ5sptrq2Gk0oa7hzUetwkz8FalEYfmHsffQ3nZnnoEJhtjWvL cXi6N6nBYVwxy3e2qFIsNH5CE/BXDwIn9dxB/RmETITr+r98H2zhoj6MT6iB+dhppizQ LUK2urjreCW9bf0/0vVA6vR1UbVnMoyFP440nw32h+EsEVlO9Zxhe1imgkVguM0kFlRc wZK7gXugPsr4cTKxmZacuhDRciCenDB4vEuVfWwpmEzGhc6j8xevhe7DCoNZMX9tROtt Iw+TL8vjTLzlh1Go3OrOGPRQzKLsCQ9gGgW7Ry2JVjNLAzDApfcwNZ42ZLMxA+4UJlzz rNfQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date; bh=3NIhY/skgAS/vlt4TesSf/0z6IIzJyzrvHiwj911Fek=; b=swnSToflDc8sBKNhxuYNZAXIgRydaHPzy9mJ1fGnwCDqbONc5VBdoPbUVLK4D4R9Fj z06sgeZRcm4yTgkwSbs64zsSRaSBO6s9eh9RZi7dTe90+hY7Mpw8U8gkFyVfVo90J8fj 3/dQO8pQyT58anilKjk/sQx6xNCCNZ41EvuiN1bPapkdVKwhV5wFFtGnpGsFnlfm+WBg xEaOJOY1kGlhvuU5qyjBn5MCd3nB6jwAvaQXJBFNiHtQmYzVUtcaKYp9usbSCG6DeqnR CMKrIlRRh+38yCOblwgaxnfY3Ggqos7a/ZhqOW5J1Tvi65gicpI0ngnS3AFJaUto5aE+ 7oEg== X-Gm-Message-State: ACgBeo3mMql3rI5q4nUBGjKyFr7rP7lzokAwnTRrsN4EmMn1JplYb0gM O2VmA5d2AsCRhVTNfZQT00sbS3UoGHBYTknEQVnCCtM+nPA= X-Google-Smtp-Source: AA6agR4WSul1yLLGq8MbQLj7dnHuNAMkOrYc4PetHTrvnKopG8IlwWCETP6+hIcleObo/nzXscY3aJYKICA1A6aMS7s= X-Received: by 2002:a17:90b:1a91:b0:1fd:c26c:a3bf with SMTP id ng17-20020a17090b1a9100b001fdc26ca3bfmr27981573pjb.213.1662509310081; Tue, 06 Sep 2022 17:08:30 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Daniele Varrazzo Date: Wed, 7 Sep 2022 01:08:18 +0100 Message-ID: Subject: Re: ImportError: symbol not found in flat namespace '_PQbackendPID' To: Gil Sousa Cc: psycopg@lists.postgresql.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Hello, On Tue, 6 Sept 2022 at 17:06, Gil Sousa wrote: > > Hi all, > > I am trying to use psycopg2 for the very first time, though I am stumblin= g with an error when trying to import the module: > > =E2=9C=97 python3.9 radars_import.py > Traceback (most recent call last): > File "/Users/gilsousa/Documents/git Projects/ReportGen/radars_import.py= ", line 2, in > import psycopg2 > File "/Users/gilsousa/Library/Python/3.9/lib/python/site-packages/psyco= pg2/__init__.py", line 51, in > from psycopg2._psycopg import ( # noqa > ImportError: dlopen(/Users/gilsousa/Library/Python/3.9/lib/python/site-pa= ckages/psycopg2/_psycopg.cpython-39-darwin.so, 0x0002): symbol not found in= flat namespace '_PQbackendPID' > > I made sure that I have the packages installed, both psycopg2 and psycopg= 2-binary. I even tried to uninstall both and just try one at a time, also d= idn'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 . See https://gist.github.com/peter-gy/0ebe072acb9065944ecb04d95a4c3096 for an example of someone fixing your problem. Cheers -- Daniele