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

完美安装成功!

相关推荐
一只AI打工虾的自我修养1 小时前
DeepSeek V4.1 vs Ollama vs LocalClaw:Mac本地AI工具横评
人工智能·windows·macos
拂晓 AI 编程2 小时前
Mac 本地跑 GUI Agent:4B 模型实现云端效果
macos
薛定猫AI2 小时前
【深度解析】Gemma Chat:基于 MLX 的 Mac 离线 Coding Agent 架构与实战
macos·架构
夏沫琅琊2 小时前
Mac 上用 Homebrew 安装 DB Browser for SQLite 时,被 Homebrew 自动更新卡住了
数据库·macos·sqlite
日月新著3 小时前
仙踪问道·爱马仕助手深度评测:Mac 本地大模型零门槛部署实录
macos
布朗克1683 小时前
Claude Code 2026中文教程指南入门:Mac/Windows安装配置全攻略
windows·macos·claude·code
2501_916007473 小时前
XCode 15 IDE新特性:苹果集成开发环境全面升级,提升编程效率与体验
ide·vscode·macos·ios·个人开发·xcode·敏捷流程
码码哈哈0.04 小时前
2026最新可用:Mac外接2k显示器开启HiDPI,支持M芯片
macos·计算机外设
故事还在继续吗1 天前
Mac 本地部署大模型
macos·llm·qwen
邵奈一1 天前
M1 Max Mac版本实测 Rapid-MLX 项目(据说比ollama快4倍)
人工智能·macos·大模型