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

完美安装成功!

相关推荐
小狮子安度因2 小时前
关于ffplay在macos上运行奔溃的问题
macos·ffmpeg
Mac技巧大咖3 小时前
恶意软件清理工具,让Mac电脑安全更简单
安全·macos·恶意软件清理工具
一丝晨光12 小时前
Windows搭建Swift语言编译环境?如何构建ObjC语言编译环境?Swift如何引入ObjC框架?Interface Builder的历史?
linux·windows·macos·ios·objective-c·xcode·swift
面壁者LOGIC12 小时前
xcode 编译运行错误 Sandbox: rsync(29343) deny(1) file-write-create
macos·xcode
面壁者LOGIC12 小时前
xcode卡死问题,无论打开什么程序xcode总是在转菊花,重启电脑,卸载重装都不行
macos·xcode
他们都不看好你,偏偏你最不争气16 小时前
iOS —— UI 初探
开发语言·macos·ui·ios·objective-c·面向对象
youshang520i17 小时前
Mac M1编译OpenCV获取libopencv_java490.dylib文件
opencv·macos
橙子小哥的代码世界1 天前
【大模型部署】mac m1本地部署 ChatGLM3-6B 超详细教程
深度学习·神经网络·macos·大模型·transformer·chatglm·踩坑记录
__WanG1 天前
Mac 每日磁盘写入量异常高
macos
lizz6661 天前
MAC软件游戏打开提示已损坏
游戏·macos