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

完美安装成功!

相关推荐
Eloudy5 小时前
MacOS 上构建 gem5
linux·运维·macos
深井冰水9 小时前
mac M2下虚拟机CentOS 8 安装上安装 Berkeley DB
数据库·macos·centos
liulilittle10 小时前
MAC-OS X 命令行设置IP、掩码、网关、DNS服务器地址
linux·网络·macos
原住民的自修室10 小时前
比 Mac 便笺更好用更好看的便利贴
笔记·macos
星卯教育tony12 小时前
苹果电脑笔记本macos Mac安装mixly 米思齐软件详细指南
macos·mixly·米思齐
黑果魏叔14 小时前
MIST:一键解锁 macOS 历史版本,旧系统安装不再难!
macos
cocochimp17 小时前
mac环境配置(homebrew版)
macos
2501_9153738818 小时前
Electron 打包与发布指南:让你的应用运行在 Windows、macOS、Linux
windows·macos·electron
心灵宝贝19 小时前
IDEA 安装 SpotBugs 插件超简单教程
java·macos·intellij-idea
名字不要太长 像我这样就好1 天前
【iOS】源码阅读(二)——NSObject的alloc源码
开发语言·macos·ios·objective-c