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

完美安装成功!

相关推荐
williamdsy8 小时前
【清除 Mac DNS 缓存】Mac 电脑能访问外网却无法加载特定页面?你的 DNS 缓存“发霉”了!
macos·缓存
xingxing_F13 小时前
Topaz Video AI for Mac AI视频无损放大 视频画质增强
人工智能·macos·音视频
2501_9151063214 小时前
iOS 打包 IPA 全流程详解,签名配置、工具选择与跨平台上传实战指南
android·macos·ios·小程序·uni-app·cocoa·iphone
行思理16 小时前
macos 下 docker使用方法 新手教程
macos·docker·容器
5pace20 小时前
Mac Nginx安装、启动、简单命令(苍穹外卖、黑马点评前端环境搭建)
java·前端·nginx·macos·tomcat
Learn Beyond Limits20 小时前
如何在Mac进行Safari网页长截图?
前端·macos·safari·方法·操作·功能·开发者平台
en-route1 天前
macOS 无法在根目录创建目录的原因与解决方案
macos
csdn_aspnet2 天前
在 MacOS 中安装 MySQL 8
mysql·macos
木兰不吃草2 天前
完美解决在最新系统 MacOS 26 无法使用 playCover 键盘映射的问题(下载安装教程,完美适配)
macos·键盘映射·playcover·mac26