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

完美安装成功!

相关推荐
醉逍遥neo44 分钟前
mac新电脑-前端开发配置
前端·macos·ghostty
夏沫琅琊1 小时前
Mac 安装cc-switch
macos
爱吃提升3 小时前
Figma汉化包下载安装教程(FigmaEX集成版Mac安装教程)|版本区别+下载方法+详细步骤+新手入门指南
macos·figma
fusugongzi3 小时前
mac本地部署deepseek
macos
无公害的小bug3 小时前
MAC系统安装SVN教程
macos·svn
钱多多_qdd4 小时前
基于mac环境,升级python环境问题解决
开发语言·python·macos
大力夯4 小时前
macOS 使用 n 模块管理 Node.js 版本
vue.js·macos·node.js
pop_xiaoli14 小时前
【iOS】RunLoop
macos·ios·objective-c·cocoa
最后一支迷迭香1 天前
苹果的MacOS系统适合做Java开发吗
java·开发语言·macos
AirDroid_cn1 天前
macOS Sequoia协同编辑:Pages文档冲突自动合并全攻略
macos