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

完美安装成功!

相关推荐
aini_lovee10 小时前
寻找 MAC 协议的 MATLAB 仿真
开发语言·macos·matlab
2501_9151063219 小时前
最新版本iOS系统设备管理功能全面指南
android·macos·ios·小程序·uni-app·cocoa·iphone
2501_9159184121 小时前
iOS 性能监控 运行时指标与系统行为的多工具协同方案
android·macos·ios·小程序·uni-app·cocoa·iphone
TheNextByte121 小时前
适用于Windows和Mac电脑的Android文件传输工具
windows·macos·电脑
Orange裴1 天前
Kali linux2025.3 安装nessus(Mac M4芯片)
linux·运维·macos·kali linux
通域1 天前
MacOS Ventura EasyConnect 安装提示 “正在等待其他安装完成“
macos
Digitally1 天前
5种将iPhone同步到Mac/MacBook的方法
macos·ios·iphone
Digitally1 天前
7种在iPhone和Mac之间传输文件的最佳方法
macos·ios·iphone
linweidong2 天前
实战救火型 从 500MB 降到 50MB:高频业务场景下的 iOS 内存急救与避坑指南
macos·ios·objective-c·cocoa·ios面试·nstimer·ios面经