无法使用 psycopg2 更改 PostgreSQL 的库版本

问题描述 投票:0回答:1

我之前已经使用 Postgresql v16 安装了 Postgresapp 应用程序并使用了一段时间。然后我意识到有时我会遇到迁移问题,因此我尝试修复并深入研究该问题。发现它在 psycopg2 中使用 Postgresapp 提供的 PostgreSQL 客户端版本 16,但我们在生产中使用 PostgreSQL 13,所以我决定在本地环境中将其降级。

我已经卸载了Postgresapp并使用brew安装了Postgresql v13(并且还尝试了Postgresapp中提供的PostgreSQL v13),但它仍在寻找PostgreSQL v16库,我收到此错误。

  Referenced from: <6C63B347-6EF3-3651-8D8C-F7B5D56B0B8E> /Users/xxxx/Library/Caches/pypoetry/virtualenvs/project-NfM96__V-py3.11/lib/python3.11/site-packages/psycopg2/_psycopg.cpython-311-darwin.so
  Reason: tried: '/Applications/Postgres.app/Contents/Versions/16/lib/libpq.5.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/Applications/Postgres.app/Contents/Versions/16/lib/libpq.5.dylib' (no such file), '/Applications/Postgres.app/Contents/Versions/16/lib/libpq.5.dylib' (no such file)

我不想做任何像符号链接这样的黑客解决方案,这只是一个覆盖范围。那么如何将此引用更改为正确的路径呢?我已经用brew重新安装了postgres@13,重新安装了psycopg2,并重新安装了诗歌环境,但它仍然在寻找错误的路径。

有什么建议吗?

ps:后来,我发现它可以与 psycopg2-binary 一起使用,或者如果我构建为wheel它可以工作,这是正确的方法吗?

python postgresql macos psycopg2
1个回答
0
投票

我已经开始使用 psycopg2-binary,并且它正在使用它。

© www.soinside.com 2019 - 2024. All rights reserved.