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

完美安装成功!

相关推荐
晴天无痕2 小时前
intel过来的xcode项目在M芯片电脑无法显示模拟器的问题日
ide·macos·xcode
Digitally3 小时前
如何连接安卓手机到 Mac?2026 年 7 种可靠方法
android·macos·智能手机
Digitally3 小时前
如何将短信从 iPhone 传输到 Mac?
macos·ios·iphone
timebeign3 小时前
Claude安装流程,系统macOS m1
macos
一块小土坷垃3 小时前
App Cleaner & Uninstaller 9.1.1 – macOS 专业级应用程序清理与卸载工具
macos·开源软件
七七powerful4 小时前
mac电脑安装cmca根证书
java·前端·macos
Front思4 小时前
安卓证书申请 + iOS 证书申请(含 Windows 无 Mac 方案)+ HBuilderX 云打包配置
android·macos·ios
云天AI实战派4 小时前
ChatGPT/AI 智能体问题排查指南:Mac Agent、语音 API、推理性能全流程修复手册
人工智能·macos·chatgpt
2601_958320571 天前
【详细版教程】Windows/macOS/Linux 安装 OpenClaw 2.6.6 指南(包含安装包)
linux·运维·windows·macos·小龙虾·open claw一键安装
HackTwoHub1 天前
可视化未授权访问批量探测工具、支持批量目标、并发扫描、SOCKS5 全局代理、CSV 导出
linux·windows·macos·网络安全·网络攻击模型