You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Mac Ventura下dbt无法识别SQL Server插件,求排查解决

问题

在Mac Ventura 13.3系统中,通过brew安装了dbt-postgres和dbt-redshift插件,现在为新项目配置dbt连接SQL Server:

  • 执行python3 -m pip install dbt-sqlserver==1.3.1完成安装
  • 配置了SQL Server的profile文件

但编译时出现无法导入sqlserver适配器,找不到该类型的适配器错误,执行dbt --version查看,插件列表中无SQL Server。

操作命令

此前安装命令

brew update
brew install git
brew tap dbt-labs/dbt
brew install dbt-postgres
brew install dbt-redshift

本次安装命令

brew update
brew install git
brew tap dbt-labs/dbt
python3 -m pip install pip --upgrade
python3 -m pip install dbt-sqlserver==1.3.1

Profile配置

mssql:
  outputs:
    dev:
      dbname: mssql
      host: host_name
      password: pwd
      port: 2433
      schema: dbo
      threads: 1
      type: sqlserver
      user: sql_user
      driver: 'ODBC Driver 18 for SQL Server' 
      trust_cert: true
  target: dev

错误日志

07:13:06  Error importing adapter: No module named 'dbt.adapters.sqlserver'
07:13:06  Encountered an error while reading profiles:
  ERROR: Runtime Error
  Credentials in profile "mssql", target "dev" invalid: Runtime Error
    Could not find adapter type sqlserver!Defined profiles:
 - mssql
For more information on configuring profiles, please consult the dbt docs:

https://docs.getdbt.com/docs/configure-your-profile

07:13:06  Encountered an error:
Runtime Error
  Could not run dbt

dbt版本信息

Core:
  - installed: 1.4.5
  - latest:    1.5.0 - Update available!

  Your version of dbt-core is out of date!
  You can find instructions for upgrading here:
  https://docs.getdbt.com/docs/installation

Plugins:
  - redshift: 1.4.0 - Update available!
  - postgres: 1.4.5 - Update available!

  At least one plugin is out of date or incompatible with dbt-core.
  You can find instructions for upgrading here:
  https://docs.getdbt.com/docs/installation

问题原因

  1. 版本不兼容:安装的dbt-sqlserver版本为1.3.1,而dbt-core版本是1.4.5,两者主版本不一致,导致适配器无法被识别。dbt插件必须与dbt-core主版本匹配(如dbt-core 1.4.x对应dbt-sqlserver 1.4.x)。
  2. 环境冲突:brew安装的dbt使用自带Python环境,而pip安装的dbt-sqlserver可能在系统默认或其他虚拟环境中,两者环境不互通,导致dbt无法找到pip安装的插件。

解决办法

方案一:统一版本并通过pip安装全套dbt(推荐)

  1. 卸载brew安装的dbt及插件:
brew uninstall dbt-postgres dbt-redshift dbt-core
brew untap dbt-labs/dbt
  1. 创建并激活虚拟环境,避免环境冲突:
python3 -m venv dbt-env
source dbt-env/bin/activate
  1. 安装匹配版本的dbt组件,确保主版本一致:
pip install dbt-core==1.4.5 dbt-sqlserver==1.4.5 dbt-postgres==1.4.5 dbt-redshift==1.4.0
  1. 执行dbt --version验证,确认sqlserver插件出现在列表中。
  2. 重新运行dbt命令检查问题是否解决。

方案二:为brew安装的dbt适配对应版本插件

若坚持使用brew安装的dbt,需在其对应的Python环境中安装匹配版本的插件:

  1. 查看brew安装的dbt使用的Python路径:
which dbt
# 或通过以下命令查看关联的Python解释器
dbt --version --verbose | grep "Python version"
  1. 使用该Python解释器安装匹配版本的dbt-sqlserver:
# 假设brew的Python路径为/usr/local/bin/python3,替换为实际路径
/usr/local/bin/python3 -m pip install dbt-sqlserver==1.4.5
  1. 验证安装后重新运行dbt命令。

额外注意

  • 确认Mac系统已正确安装ODBC Driver 18 for SQL Server,可通过odbcinst -j命令查看已安装驱动。
  • 使用虚拟环境时,每次运行dbt前需先激活虚拟环境。

内容的提问来源于stack exchange,提问作者Lee

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.22 15:32:28