0

我尝试安装 SQL Server 命令行工具,但出现下一个错误

sql-tools unixodbc-dev
Reading package lists... Done
Building dependency tree       
Reading state information... Done
mssql-tools is already the newest version (17.6.1.1-1).
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:
 mssql-tools : Depends: msodbcsql17 (>= 17.3.0.0) but it is not going to be installed
 unixodbc-dev : Depends: unixodbc (= 2.3.7)
                Depends: odbcinst1debian2 (= 2.3.7) but it is not going to be installed
E: Unable to correct problems, you have held broken packages.

我尝试使用sudo apt install msodbcsql17 sudo apt-get install unixodbc但使用第二个命令得到了类似的错误。

4

1 回答 1

0

根据您问题中的版本号,您似乎curl从 Microsoft在 Ubuntu 16.04文档上的安装工具中运行了以下命令:

$ curl https://packages.microsoft.com/config/ubuntu/16.04/prod.list | sudo tee /etc/apt/sources.list.d/msprod.list
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100    79  100    79    0     0    163      0 --:--:-- --:--:-- --:--:--   163
deb [arch=amd64] https://packages.microsoft.com/ubuntu/16.04/prod xenial main

如果你在 Ubuntu 20.04 上这样做,那么apt-get install将会失败:

$ sudo apt-get install -y mssql-tools 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:
 mssql-tools : Depends: msodbcsql17 (>= 17.3.0.0) but it is not going to be installed
 unixodbc-dev : Depends: unixodbc (= 2.3.7) but it is not going to be installed
                Depends: odbcinst1debian2 (= 2.3.7) but it is not going to be installed
E: Unable to correct problems, you have held broken packages.

根据文档,您需要更改存储库 URL 中的版本号以匹配您的 Ubuntu 版本,因此请curl在 Ubuntu 18.04 上使用以下命令:

curl https://packages.microsoft.com/config/ubuntu/18.04/prod.list | sudo tee /etc/apt/sources.list.d/msprod.list

以及 Ubuntu 20.04 上的以下curl命令:

curl https://packages.microsoft.com/config/ubuntu/20.04/prod.list | sudo tee /etc/apt/sources.list.d/msprod.list

下载正确的存储库引用并执行命令后,应成功完成apt-get updateapt-get install

于 2021-06-03T05:02:42.510 回答