Mac 安装psycopg2出错:Error:pg_config executable not found的解决

在mac 上执行pip3 install psycopg2-binary出现如下错误:

python 复制代码
Error:pg_config executable not found

然后我又到终端里执行

python 复制代码
brew install  postgresql@16 

显示

python 复制代码
Warning: You are using macOS 15.
We do not provide support for this pre-release version.
It is expected behaviour that some formulae will fail to build in this pre-release version.
It is expected behaviour that Homebrew will be buggy and slow.
Do not create any issues about this on Homebrew's GitHub repositories.
Do not create any issues even if you think this message is unrelated.
Any opened issues will be immediately closed without response.
Do not ask for help from Homebrew or its maintainers on social media.
You may ask for help in Homebrew's discussions but are unlikely to receive a response.
Try to figure out the problem yourself and submit a fix as a pull request.
We will review it but may or may not accept it.

以为是安装的psycopg2 版本问题,试了安装15、16都出现以上警告。

解决办法:

1、更新brew版本

python 复制代码
brew update

2、然后再安装postgresql@16

python 复制代码
brew install postgresql@16

postgresql安装成功

3、添加路径

python 复制代码
vim ~/.bash_profile
python 复制代码
export PATH="/opt/homebrew/opt/postgresql@16/bin:$PATH"
export LDFLAGS="-L/opt/homebrew/opt/postgresql@16/lib"
export CPPFLAGS="-I/opt/homebrew/opt/postgresql@16/include"

保存后退出,

再执行

python 复制代码
source ~/.bash_profile

4、安装psycopg2-binary

到IDE中,执行

python 复制代码
pip3 install psycopg2-binary

完美安装成功!

相关推荐
小钱c73 小时前
关于Mac使用VSCode连接虚拟机
ide·vscode·macos
Batac_蝠猫8 小时前
iOS - 自定义引用计数(MRC)
macos·ios·cocoa
SoraLuna11 小时前
「Mac畅玩鸿蒙与硬件53」UI互动应用篇30 - 打卡提醒小应用
macos·ui·harmonyos
Danny_姜11 小时前
荒腔走板Mac电脑本地部署 LLM
macos
伊织code11 小时前
报错 - decord 在 macOS Silicon 安装失败
macos·m2·decord·silicon·eva-decord
大土豆的bug记录11 小时前
Mac上鸿蒙配置HDC报错:zsh: command not found: hdc -v
macos·华为·harmonyos·arkts·鸿蒙·arkui
小远披荆斩棘11 小时前
关于Mac中的shell
macos
深度Linux11 小时前
以太网MAC和PHY层问题的“对症下药”攻略
linux·网络·macos
我是Superman丶12 小时前
【工具】HTML自动识别用户正在讲话 以及停止讲话
ide·macos·xcode
Batac_蝠猫1 天前
iOS - 引用计数(ARC)
macos·ios·xcode