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

完美安装成功!

相关推荐
梅名智3 小时前
IOS 蓝牙连接
macos·ios·cocoa
帅次17 小时前
Objective-C面向对象编程:类、对象、方法详解(保姆级教程)
flutter·macos·ios·objective-c·iphone·swift·safari
fengyun289117 小时前
fcpx音视频剪辑编辑 Final Cut Pro X(Mac电脑)
macos·mac
fengyun289118 小时前
Mac电脑 卸载工具 App Cleaner
macos
aerror1 天前
Xbox One 控制器转换为 macOS HID 设备的工作原理分析
macos·xbox
晴风向上1 天前
mac mini m4安装node.js@16以下版本方法
macos·node.js
JPCstorm1 天前
Mac homebrew 安装教程
macos
秋窗71 天前
Mac 部署Latex OCR并优化体验(打包成App并支持全局快捷键)
macos·ocr·latex
FreeBuf_1 天前
朝鲜APT组织使用Nim语言恶意软件对macOS发起隐秘Web3与加密货币攻击
macos·web3·策略模式
Digitally1 天前
如何将信息从 iPhone 同步到Mac(完整步骤和示意图)
macos·ios·iphone