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

完美安装成功!

相关推荐
星野爱8958 小时前
崩坏星穹铁道4.4版本即将前瞻!Mac畅玩PC端开荒新版本
macos
funnycoffee12310 小时前
lacp报文占多少字节?报文的目的mac
网络·网络协议·macos
itwangyang52013 小时前
Claude Code macOS 安装完整指南:Homebrew、原生脚本与常见问题解决
macos
汤姆yu1 天前
macOS系统下Aider完整安装、配置与实战使用教程
大数据·人工智能·算法·macos·github·copilot
码云数智-园园1 天前
SwiftUI 6 生产落地踩坑实录
macos·objective-c·cocoa
向阳是我1 天前
在 Mac(M2)上用 faster-whisper 实现高精度中文语音转文字
python·macos·ai·whisper·语音识别
Tisfy1 天前
MacOS:首次外接键盘初始化设置(Option/Command互换、左上角·~而非§±)
macos·计算机外设
小鹿软件办公2 天前
如何利用 Mac 自带 iMovie 裁剪去除视频 Logo 或文字水印
macos·音视频·视频去水印·简鹿水印助手
一个假的前端男2 天前
在 macOS 上通过 VirtualBox 安装 Home Assistant 完整教程
macos