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

完美安装成功!

相关推荐
一个人旅程~4 小时前
如何避免在使用win安装U盘启动macbook时候出现键盘触摸板卡死的问题
windows·经验分享·macos·电脑
开开心心loky8 小时前
[OC 底层] (三) 方法缓存与消息发送机制
macos·ios·缓存·objective-c·cocoa
月诸清酒9 小时前
豆包输入法 Mac 版上线了,跟我之前用的 Typeless 对比了下
macos
星辰即远方9 小时前
UICollectionView
macos·objective-c·cocoa
水云桐程序员10 小时前
APP 的架构设计
macos·objective-c·cocoa·软件工程
开开心心loky11 小时前
[OC 底层] (四) 多线程相关内容
macos·ios·objective-c·cocoa
白玉cfc12 小时前
【iOS】底层原理:理解dyld
macos·objective-c·cocoa
我欲扶摇九万里13 小时前
Mac版idea快捷键失效的原因及解决方法
java·macos·intellij-idea
秋雨梧桐叶落莳14 小时前
iOS——UIStackView学习
学习·macos·ios·objective-c·cocoa
liyoro1 天前
用 Codex + 提示词生成一个快速打开 Ghostty 的 macOS 小工具
macos·shell·ai编程