我试图使用pyodbc连接到python中的MSSQL数据库。我已经按照使用19.04版本的这里指令安装了MS驱动程序。当试图通过pip安装pyodbc时,我得到了sql.h: No such file or directory。谷歌告诉我,我需要安装unixodbc和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自动清洗,apt安装-f等没有做任何事情。
发布于 2019-10-23 15:02:11
看来,在19.10上的unixODBC驱动程序中存在一个问题(具体来说,驱动程序提供的unixODBC的依赖项之一依赖于multiarch-support,它存在于所有其他Ubuntus,而不是19.10)。
要了解这一点,您可以从http://www.unixodbc.org/下载包(请参阅右侧的下载按钮),然后按照说明手动安装它。或者通过执行以下操作来安装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 msodbcsql17https://askubuntu.com/questions/1183140
复制相似问题