在 19.10 上安装 unixodbc

nik*_*noe 5 odbc 19.10

我正在尝试使用 pyodbc 连接到 python 中的 MSSQL 数据库。我已经按照此处的说明使用 19.04 版本安装了 MS 驱动程序。尝试通过 pip 安装 pyodbc 时,我得到sql.h: No such file or directory. 谷歌搜索告诉我我需要安装unixodbcunixodbc-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.
Run Code Online (Sandbox Code Playgroud)

运行 apt autoclean、apt install -f 等没有做任何事情。

Max*_*xim 6

似乎 19.10 上的 ODBC 驱动程序附带的 unixODBC 存在问题(特别是驱动程序随附的 unixODBC 的依赖项之一multiarch-support出于某种原因依赖于所有其他 Ubuntu,但不存在于19.10)

要解决这个问题,您可以从http://www.unixodbc.com/(下载页面)下载软件包,然后按照说明手动安装它。或者通过执行以下操作安装 Ubuntu 存储库中的默认 unixODBC:

#delete the package info, so that apt doesn't try to use that version of unixODBC
sudo rm /etc/apt/sources.list.d/mssql-release.list

#install the default one
sudo apt install unixodbc

#re-add the package and install the driver
sudo su
curl https://packages.microsoft.com/config/ubuntu/19.04/prod.list > /etc/apt/sources.list.d/mssql-release.list
exit
sudo apt install msodbcsql17
Run Code Online (Sandbox Code Playgroud)