【问题标题】:Unable to connect to SQL Server with Kerberos when transformers library is installed安装转换器库后无法使用 Kerberos 连接到 SQL Server
【发布时间】:2023-02-01 08:35:43
【问题描述】:

我正在尝试使用 Python 中的 Kerberos 身份验证连接到 mssql 数据库。当我的 anaconda 环境刚刚安装了 pyodbc 时,我可以连接并向数据库发送查询。但是当我将 huggingface 的 transformer 库添加到环境中时,出现以下错误:

Error: ('HY000', '[HY000] [Microsoft][ODBC Driver 17 for SQL Server]SSPI Provider: No credentials were supplied, or the credentials were unavailable or inaccessible. No Kerberos credentials available: No KCM server found (458752) (SQLDriverConnect)')

一个在没有安装转换器库的情况下工作的示例函数是

import pyodbc
def pyodbc_query(query):

    cnxn = pyodbc.connect(
        Trusted_Connection='Yes',
        Driver='{/opt/microsoft/msodbcsql17/lib64/libmsodbcsql-17.2.so.0.1}',
        Server='servername',
        Database='database'
    )
    cursor = cnxn.cursor()
    cursor.execute(query)
    result = cursor.fetchall()

    return result

我也尝试过使用 sqlalchemy 而不是 pyodbc,结果相同。我的 pyodbc 版本是 4.0.35,我的 transfromers 版本是 4.26.0。有没有人有同样的问题?

【问题讨论】:

    标签: sql odbc kerberos huggingface-transformers


    【解决方案1】:

    万一其他人偶然发现了这个: 问题是 transformers 下载库 krb5 作为依赖项,这个包会弄乱系统的 Kerberos 系统配置。如果您不需要其他任何东西,您可以使用 conda remove krb5 --force -y 卸载 krb5。 github 问题中提供了更多信息: https://github.com/ContinuumIO/anaconda-issues/issues/10772

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-12-26
      • 2020-02-11
      • 2016-03-20
      • 1970-01-01
      相关资源
      最近更新 更多