尝试安装 python-dev 时出现包损坏问题

尝试安装 python-dev 时出现包损坏问题

我需要安装 python-dev 才能安装另一个应用程序,但是当我这样做时,sudo apt-get install python-dev我得到:The following packages have unmet dependencies:带有依赖项列表。所以我添加它们直到不再有依赖项,将命令行保留为:sudo apt-get install python-dev libpython2.7-dev python2.7-dev libexpat1-dev libexpat1

之后我得到:

The following packages have unmet dependencies:
     libexpat1-dev : Depends: libexpat1 (= 2.1.0-6+b3) but 2.1.0-6+deb8u1 is to be installed
E: Unable to correct problems, you have held broken packages.

我打开 Synaptic 并搜索损坏的软件包,但没有找到。我还尝试使用 aptitude 而不是 apt-get:

 The following NEW packages will be installed:
  libexpat1-dev{ab} libpython-dev{a} libpython2.7-dev{a} python-dev
  python2.7-dev{a}
0 packages upgraded, 5 newly installed, 0 to remove and 0 not upgraded.
Need to get 0 B/19.0 MB of archives. After unpacking 31.6 MB will be used.
The following packages have unmet dependencies:
 libexpat1-dev : Depends: libexpat1 (= 2.1.0-6+b3) but 2.1.0-6+deb8u1 is installed.

 The following actions will resolve these dependencies:

     Keep the following packages at their current version:
1)     libexpat1-dev [Not Installed]                     
2)     libpython-dev [Not Installed]                     
3)     libpython2.7-dev [Not Installed]                   
4)     python-dev [Not Installed]                         
5)     python2.7-dev [Not Installed]

Accept this solution? [Y/n/q/?] 

到目前为止一切顺利(我认为),所以我按了“Y”,但它列出了很多要删除的软件包并要求我继续。由于我对此有疑问,所以我按了“n”,但现在当我再次复制建议删除的包时,它什么也没做:

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.

任何帮助将不胜感激。提前致谢。

编辑:

现在我正在使用本地存储库,因为我在连接到 debian ftp 时遇到问题(可能是因为网络管理员或代理)。所以我的sources.lst是:

#deb http://ftp.debian.org/debian/ jessie main contrib non-free
#deb-src http://ftp.debian.org/debian/ jessie main contrib non-free

#deb http://security.debian.org/ jessie/updates main contrib non-free
#deb-src http://security.debian.org/ jessie/updates main contrib non-free

# jessie-updates, previously known as 'volatile'
# A network mirror was not selected during install.  The following entries
# are provided as examples, but you should amend them as appropriate
# for your mirror of choice.
#
#deb http://ftp.debian.org/debian/ jessie-updates main contrib non-free
#deb-src http://ftp.debian.org/debian/ jessie-updates main contrib non-free

##Local Repository
deb file:/media/ramon-debian/JimiHendrix/debian8repo/debian jessie main contrib non-free
deb file:/media/ramon-debian/JimiHendrix/debian8repo/debian stable main contrib non-free

答案1

您使用的存储库有问题。 https://tracker.debian.org/pkg/expat显示在 Debian 中,没有软件包libexpat1_2.1.0-6+b3...

使用 删除 apt 缓存rm -rf /var/lib/apt/lists/*,然后apt-get update再次删除。如果您的本地镜像正常,您应该有一个可用软件包的工作(一致)列表。如果没有,那么本地存储库已损坏......

答案2

问题解决了!我libexpat1_2.1.0-7_amd64.deblibexpat1-dev_2.1.0-7_amd64.deb链接下载了软件包@Jan 发布并安装它们dpkg -i package.deb

答案3

使用该aptitude工具 - 您会经常看到此建议,但没有说明。我在 GNU Radio PyBOMBS 构建(在 Raspberry Pi 3b 上,FWIW)上遇到了类似的问题,无论改变多少镜子、rm -rf /var/lib/apt/lists/*apt-get clean都无法解决。

如果你的镜像有目标包,aptitude我的修复方法是否定正如您所经历的,第一个解决方案什么也没做。然后,第二个解决方案是降级,安装了所需的依赖项!

我会得到:

libevent-dev : Depends: libevent-2.0-5 (= 2.0.21-stable-2) but 2.0.21-stable-2+deb8u1 is to be installed

这是我的解决方案(对于 libevent-dev,但应该适用于 libexpat1-dev):

# aptitude install libevent-dev
The following NEW packages will be installed:
  libevent-core-2.0-5{a} libevent-dev{b} libevent-extra-2.0-5{a} libevent-openssl-2.0-5{a} 
  libevent-pthreads-2.0-5{a} 
0 packages upgraded, 5 newly installed, 0 to remove and 0 not upgraded.
Need to get 506 kB of archives. After unpacking 1586 kB will be used.
The following packages have unmet dependencies:
 libevent-dev : Depends: libevent-2.0-5 (= 2.0.21-stable-2) but 2.0.21-stable-2+deb8u1 is installed.
The following actions will resolve these dependencies:

     Keep the following packages at their current version:
1)     libevent-dev [Not Installed]                       

Accept this solution? [Y/n/q/?] n
The following actions will resolve these dependencies:

     Downgrade the following packages:                                          
1)     libevent-2.0-5 [2.0.21-stable-2+deb8u1 (now) -> 2.0.21-stable-2 (stable)]

Accept this solution? [Y/n/q/?] y
The following packages will be DOWNGRADED:
  libevent-2.0-5 
The following NEW packages will be installed:
  libevent-core-2.0-5{a} libevent-dev libevent-extra-2.0-5{a} libevent-openssl-2.0-5{a} 
  libevent-pthreads-2.0-5{a} 
0 packages upgraded, 5 newly installed, 1 downgraded, 0 to remove and 0 not upgraded.
Need to get 641 kB of archives. After unpacking 1552 kB will be used.
Do you want to continue? [Y/n/?] y

之后,我可以恢复 PyBOMBS 构建并满足依赖关系(好吧,在对 libboost-dev 进行类似的修复之后......)。

相关内容