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

完美安装成功!

相关推荐
山楂树の35 分钟前
模型优化——在MacOS 上使用 Python 脚本批量大幅度精简 GLB 模型(通过 Blender 处理)
python·macos·3d·图形渲染·blender
光头才能变强3 小时前
Mac安装Navicat教程Navicat Premium for Mac v17.1.9 Mac安装navicat【亲测】
macos
Frilled Lizard7 小时前
解决mac下git pull、push需要输入密码
git·macos
是小崔啊9 小时前
Mac下的Homebrew
macos
0wioiw01 天前
Apple基础(Xcode①-项目结构解析)
ide·macos·xcode
名字不要太长 像我这样就好1 天前
【iOS】weak修饰符
macos·ios·objective-c·cocoa·xcode
ghostwritten1 天前
在 Mac 上用 Vagrant 安装 K8s
macos·kubernetes·vagrant
胡萝卜大王驾到通通闪开2 天前
Mac m系列芯片安装node14版本使用nvm + Rosetta 2
macos
java叶新东老师2 天前
ubuntu资源共享samba 安装与配置 mac/windows共享ubuntu文件资源
windows·ubuntu·macos
归辞...2 天前
「iOS」————MRC
macos·ios·cocoa