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

完美安装成功!

相关推荐
一个小浪吴啊21 小时前
MacOS/Linux/Windows 跨平台一键安装OpenCode指南
linux·windows·macos·opencode
小草cys21 小时前
最简单:一根网线直连,mac mini Windows 控制 Mac mini mac
windows·macos·局域网直连
白玉cfc1 天前
OC底层原理:alloc&init&new
c++·macos·ios·objective-c·xcode
Mike_detailing1 天前
资源分享:VMware-Fusion-25H2u1 和 arm版本win11
macos·arm·虚拟机
承渊政道1 天前
【递归、搜索与回溯算法】(掌握记忆化搜索的核心套路)
数据结构·c++·算法·leetcode·macos·动态规划·宽度优先
REDcker1 天前
跨平台编译详解 工具链配置与工程化实践
linux·c++·windows·macos·c·跨平台·编译
白豆五1 天前
Mac平台安装Claude Code
macos
寂夜了无痕1 天前
macOS 下 `ls: .: Operation not permitted
macos
库奇噜啦呼2 天前
【iOS】内存对齐原理
macos·ios·cocoa
子沫20202 天前
mac下载VMware Fusion
macos·mac·vmware fusion