尝试在 Ubuntu 18.04 上安装 clang 时出现软件包损坏的情况

尝试在 Ubuntu 18.04 上安装 clang 时出现软件包损坏的情况

我尝试在 Ubuntu 18.04 上安装 clang,但无法安装。我尝试sudo apt install clang并得到了以下结果:

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:
 clang : Depends: clang-6.0 (>= 6.0~) but it is not going to be installed
E: Unable to correct problems, you have held broken packages.

我阅读了一些关于保留包裹的答案并尝试过sudo aptitude install clang,但也没有用。

我得到了以下结果:

The following NEW packages will be installed:
  clang-6.0 lib32gcc1{ab} lib32stdc++6{ab} libc6-i386{a} libclang-common-6.0-dev{a} libclang1-6.0{a} libffi-dev{a} libjsoncpp1{a} libobjc-7-dev{ab} libobjc4{ab} libpython-stdlib{a} libtinfo-dev{ab} 
  llvm-6.0{a} llvm-6.0-dev{a} llvm-6.0-runtime{a} python{a} python-minimal{a} python2.7{ab} python2.7-minimal{ab} 
0 packages upgraded, 19 newly installed, 0 to remove and 0 not upgraded.
Need to get 53.4 MB of archives. After unpacking 313 MB will be used.
The following packages have unmet dependencies:
 lib32stdc++6 : Depends: gcc-8-base (= 8-20180414-1ubuntu2) but 8.3.0-6ubuntu1~18.04 is installed
 libobjc4 : Depends: gcc-8-base (= 8-20180414-1ubuntu2) but 8.3.0-6ubuntu1~18.04 is installed
 python2.7-minimal : Depends: libpython2.7-minimal (= 2.7.15~rc1-1) but 2.7.15~rc1-1ubuntu0.1 is installed
 python2.7 : Depends: libpython2.7-stdlib (= 2.7.15~rc1-1) but 2.7.15~rc1-1ubuntu0.1 is installed
 lib32gcc1 : Depends: gcc-8-base (= 8-20180414-1ubuntu2) but 8.3.0-6ubuntu1~18.04 is installed
 libobjc-7-dev : Depends: gcc-7-base (= 7.3.0-16ubuntu3) but 7.4.0-1ubuntu1~18.04 is installed
                 Depends: libgcc-7-dev (= 7.3.0-16ubuntu3) but 7.4.0-1ubuntu1~18.04 is installed
 libtinfo-dev : Depends: libtinfo5 (= 6.1-1ubuntu1) but 6.1-1ubuntu1.18.04 is installed
The following actions will resolve these dependencies:

      Keep the following packages at their current version:
1)      clang-6.0 [Not Installed]                          
2)      lib32gcc1 [Not Installed]                          
3)      lib32stdc++6 [Not Installed]                       
4)      libclang-common-6.0-dev [Not Installed]            
5)      libobjc-7-dev [Not Installed]                      
6)      libobjc4 [Not Installed]                           
7)      libtinfo-dev [Not Installed]                       
8)      llvm-6.0-dev [Not Installed]                       
9)      python [Not Installed]                             
10)     python-minimal [Not Installed]                     
11)     python2.7 [Not Installed]                          
12)     python2.7-minimal [Not Installed]                  

      Leave the following dependencies unresolved:         
13)     python-minimal recommends python                   
14)     python2.7-minimal recommends python2.7             
15)     clang-6.0 recommends python                        
16)     llvm-6.0 recommends llvm-6.0-dev                   

Accept this solution? [Y/n/q/?] y
No packages will be installed, upgraded, or removed.
0 packages upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
Need to get 0 B of archives. After unpacking 0 B will be used.

答案1

如..所示这里您需要在 sources.list 中启用 bionic-updates 套件,并将
以下块添加到 /etc/apt/sources.list 的前面或后面

deb http://archive.ubuntu.com/ubuntu bionic main multiverse restricted universe
deb http://archive.ubuntu.com/ubuntu bionic-security main multiverse restricted universe
deb http://archive.ubuntu.com/ubuntu bionic-updates main multiverse restricted universe

#deb-src http://archive.ubuntu.com/ubuntu bionic main multiverse restricted universe
#deb-src http://archive.ubuntu.com/ubuntu bionic-security main multiverse restricted universe
#deb-src http://archive.ubuntu.com/ubuntu bionic-updates main multiverse restricted universe

如果您需要来自存储库的源代码,请取消注释 deb-src 行。
然后只需运行sudo apt update; sudo apt install clang就可以了。

相关内容