我正在尝试使用 pyodbc 连接到 python 中的 MSSQL 数据库。我已经按照此处的说明使用 19.04 版本安装了 MS 驱动程序。尝试通过 pip 安装 pyodbc 时,我得到sql.h: No such file or directory
. 谷歌搜索告诉我我需要安装unixodbc
and unixodbc-dev
,但是当我尝试这样做时,我收到以下消息:
Reading package lists... Done
Building dependency tree
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:
The following packages have unmet dependencies:
unixodbc : Depends: odbcinst1debian2 (>= 2.3.7) but it is not going to be installed
Depends: libodbc1 (>= 2.3.7) but it is not going to be installed
E: Unable to correct problems, you have held broken packages.
运行 apt autoclean、apt install -f 等没有做任何事情。
似乎 19.10 上的 ODBC 驱动程序附带的 unixODBC 存在问题(特别是驱动程序提供的 unixODBC 的依赖项之一取决于
multiarch-support
某种原因,它存在于所有其他 Ubuntu 上,但不存在于19.10)要解决这个问题,您可以从http://www.unixodbc.org/下载软件包(参见右侧的下载按钮)并按照说明手动安装。或者通过执行以下操作安装 Ubuntu 存储库中的默认 unixODBC: