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

完美安装成功!

相关推荐
阿赛工作室14 小时前
mac系统使用Hbuilderx调试安装app
macos
weixin_4624462319 小时前
Linux/Mac 一键自动配置 JAVA_HOME 环境变量(含 JDK 完整性校验)
java·linux·macos
Frank学习路上19 小时前
【Qt】问题记录ld: framework ‘AGL‘ not found on MacOS 26
开发语言·qt·macos
SoraLuna19 小时前
KuiklyUI for OpenHarmony 实战 02:Kuikly 工程创建与鸿蒙运行(Mac)
macos·华为·harmonyos
微信-since8119221 小时前
【mac】 mac使用
macos
REDcker2 天前
macOS「系统数据」暴涨到 几百GB?一篇文章教你安全清理(含排查顺序)
macos
sysinside2 天前
macOS Sequoia 15.7.2 (24G325) 正式版 ISO、IPSW、PKG 下载
macos·sequoia
只是有点小怂2 天前
macOS 没有像 Windows 上的 MobaXterm 的工具
macos
小雨青年2 天前
环境准备 Windows Mac 下 Docker Desktop 的安装与镜像源加速
windows·macos·docker
数据知道2 天前
一文掌握 MongoDB 详细安装与配置(Windows / Linux / macOS 全平台)
linux·数据库·windows·mongodb·macos