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

完美安装成功!

相关推荐
Unlimitedz1 小时前
iOS GCD
macos·ios·cocoa
Unlimitedz2 小时前
深入探索 iOS 卡顿优化
macos·ios·cocoa
Alger_Hamlet13 小时前
Final Cut Pro X for Mac fcpx音视频剪辑编辑
macos
小雅痞15 小时前
[Mac]利用Hexo+Github Pages搭建个人博客
macos·hexo·github.io
coding随想15 小时前
macOS (M1 Pro) 上 Docker Desktop 安装失败问题及其解决方案
macos·docker·容器
coding随想20 小时前
解决 macOS (M1 Pro) 上使用 Vite 进行 Build 打包时 Node 进程内存溢出的问题
macos·node.js
Tee xm21 小时前
清晰易懂的Rust安装与配置教程
linux·windows·macos·rust
Billy Qin1 天前
【Mac】npm error Error: EACCES: permission denied, mkdir‘/Users/...
前端·macos·npm
马拉萨的春天2 天前
mac 下配置flutter 总是失败,请参考文章重新配置flutter 环境MacOS Flutter环境配置和安装
flutter·macos
yinshuilan2 天前
Tabby 一:如何在Mac配置保姆级教程(本地模型替换hugging face下载)
macos·ai编程·tabby·ai模型