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

完美安装成功!

相关推荐
努力冲冲19 小时前
Mac 选择下载安装工具 x86 还是 arm64 ?
macos
xybDIY21 小时前
【Amazon 工具】在MacOS本地安装 AWS CLI、kubectl、eksctl工具
macos·云计算·aws
深兰科技1 天前
“AI问诊助手”落地武汉市中心医院,深兰科技助力医疗数智化升级
人工智能·macos·intellij-idea·phpstorm·深兰科技·武汉市中心医院·ai问诊助手
How_doyou_do1 天前
Mac-VScode-C++环境配置
c++·vscode·macos
一棵树长得超出它自己3 天前
Allure安装与使用【macOS】
macos
三金C_C4 天前
Mac配置开发环境
macos·开发环境
阿7_QuQ4 天前
Mac屏幕共享怎么使用?
运维·服务器·macos
Doris Liu.4 天前
macOS取证分析——Safari浏览器、Apple Mail数据和Recents数据库
数据库·macos·缓存·sqlite·safari·电子数据取证·macos取证
Brian_Lucky4 天前
macOS安装未验证软件报错解决:以FinalShell为例的完整指南
macos
yzwdzkn4 天前
解决Flutter 2.10.5在升级Xcode 16后的各种报错
flutter·macos·xcode