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

Apple Silicon Mac上配置Stata 16连接Postgres WRDS数据库遇ODBC问题

解决Stata连接WRDS(Postgres ODBC)时libodbc.dylib找不到的问题

问题说明

  • 博士研究中使用Stata代码连接WRDS数据库(基于Postgres的ODBC数据库)
  • Terminal中isql可正常连接,但Stata执行odbc list时返回错误:

The ODBC file libodbc.dylib could not be found on this system. Setting the unix LD_LIBRARY_PATH environment variable may correct this error.

  • 已通过Homebrew和psqlodbc完成适配配置,当前从终端启动Stata的命令为:
export LD_LIBRARY_PATH=/opt/homebrew/lib/ && /Applications/Stata/StataSE.app/Contents/MacOS/StataSE &

解决方案

1. 修正环境变量名称

Mac系统不使用LD_LIBRARY_PATH作为动态库路径变量,正确变量为DYLD_LIBRARY_PATH,修改启动命令为:

export DYLD_LIBRARY_PATH=/opt/homebrew/lib/ && /Applications/Stata/StataSE.app/Contents/MacOS/StataSE &

若需保留系统原有动态库路径,可采用追加方式避免覆盖:

export DYLD_LIBRARY_PATH="$DYLD_LIBRARY_PATH:/opt/homebrew/lib/" && /Applications/Stata/StataSE.app/Contents/MacOS/StataSE &

2. 确认库文件实际位置

先在终端执行以下命令,验证libodbc.dylib的实际路径:

find /opt/homebrew -name libodbc.dylib

若返回路径与/opt/homebrew/lib/不符,将启动命令中的路径替换为实际找到的地址。

3. 验证Stata内环境变量加载情况

启动Stata后,执行以下命令查看环境变量是否正确加载:

shell echo $DYLD_LIBRARY_PATH

输出应包含/opt/homebrew/lib/(或实际库文件路径)。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.03 21:25:43