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

完美安装成功!

相关推荐
RobinDevNotes2 天前
24GB Mac 做数字人:声音放本地,画面租云端
人工智能·python·macos·开发工具
oil欧哟4 天前
Oil Studio 的产品思路与日常使用方式:在 Mac 上录口播演示,并接入 AI Agent 精剪与自动录屏
人工智能·macos
小毛球.5 天前
第 3 篇:IDEA 最新版下载与完整安装教程(Mac)
java·macos·intellij-idea·idea
CodeClimb7 天前
Mac 磁盘无法推出(DMG外接盘)排查处理教程
macos
Karl_fang7 天前
🥳 再也不用拿起手机抄验证码!我做了一个 Android → Mac 的「验证码接力」工具
前端·macos·ai编程
csdn_aspnet9 天前
macOS 10 、Docker 玩轉 MySQL
运维·mysql·macos·docker·容器·mac
秋雨梧桐叶落莳9 天前
【iOS】Block底层详解
macos·ios·cocoa
高调的涵涵11 天前
café 和 café 不是一个文件名
macos
独隅13 天前
WebStorm macOS 安装部署与高效调优完全指南
ide·macos·webstorm
独隅13 天前
WebStorm macOS 安装调优与实战效能全景
ide·macos·webstorm