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

完美安装成功!

相关推荐
开开心心loky13 分钟前
[OC 底层] (五) iOS 中常见的几种锁
macos·ios·cocoa
技术小结-李爽5 小时前
Mac快捷键设计规律总结
macos·键盘
铁锚5 小时前
macOS 禁用 mediaanalysisd
macos·策略模式
酉鬼女又兒7 小时前
零基础入门计算机网络:MAC地址、IP地址与ARP协议全面解析(含考研真题详解)
网络·网络协议·tcp/ip·计算机网络·考研·macos·职场和发展
资源分享助手7 小时前
PeekDesktop:实现类似 macOS Sonoma 点击桌面预览(Windows工具教程)
windows·macos·点击回到桌面
鹤卿1238 小时前
iOS OC NSUserDefaults
macos·ios·objective-c
元Y亨H16 小时前
Mac 进阶效率手册:从操作熟练到效率飞升
macos
开开心心就好1 天前
无弹窗不更新的PC本地播放工具
运维·科技·macos·docker·计算机外设·ocr·powerpoint
小王师傅661 天前
深入解析:Docker在Mac上的运行本质与Linux进程管理机制
linux·macos·docker
微步_ym1 天前
Docker:在Mac的docker.desktop中安装mongo
macos·docker·容器