由于“解析时发生了一些异常”错误,无法安装软件包

由于“解析时发生了一些异常”错误,无法安装软件包

我正在跟进这些说明在我的笔记本电脑上安装 git。
当我这样做时:

$ sudo apt-get install git-core

这是我的终端显示的内容:

Reading package lists... Done
Building dependency tree        
Reading state information... Done
The following packages were automatically installed and are no longer required:   
  libasprintf0c2:i386
  libcroco3:i386
  libgettextpo0:i386
  libgomp1:i386
  libunistring0:i386
Use 'apt-get autoremove' to remove them.
The following extra packages will be installed:
  git git-man liberror-perl
Suggested packages:
  git-daemon-run
  git-daemon-sysvinit
  git-doc git-el
  git-arch git-cvs
  git-svn
  git-email
  git-gui
  gitk gitweb
The following NEW packages will be installed:
  git git-core git-man liberror-perl

 0 upgraded, 4 newly installed, 0 to remove and 0 not upgraded.
 Need to get 6,825 kB of archives. After this operation, 15.3 MB of additional disk space will be used. Do you want to continue [Y/n]? y
 WARNING: The following packages cannot be authenticated!
   liberror-perl git-man git git-core
Install these packages without verification [y/N]?

  E: Some packages could not be authenticated
lucas@lucas-Inspiron-N5050:~$ sudo apt-get install git-core
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages were automatically installed and are no longer required:
  libasprintf0c2:i386
  libcroco3:i386
  libgettextpo0:i386
  libgomp1:i386
  libunistring0:i386
Use 'apt-get autoremove' to remove them.
The following extra packages will be installed:
  git git-man liberror-perl
Suggested packages:
  git-daemon-run git-daemon-sysvinit
  git-doc git-el git-arch git-cvs git-svn
  git-email git-gui gitk gitweb
The following NEW packages will be installed:
  git git-core
  git-man liberror-perl
 0 upgraded, 4 newly installed, 0 to remove and 0 not upgraded.
 Need to get 6,825 kB of archives. After this operation, 15.3 MB of additional disk space will be used. Do you want to continue [Y/n]? y
WARNING: The following packages cannot be authenticated!
  liberror-perl git-man git git-core
Install these packages without verification [y/N]? y
Err httpq://py.archive.ubuntu.com/ubuntu/quantal/main liberror-perl all 0.17-1
   Something wicked happened resolving 'py.archive.ubuntu.com:http' (-5 - No address associated with hostname)
Err httpq://py.archive.ubuntu.com/ubuntu/ quantal/main git-man all 1:1.7.10.4-1ubuntu1
   Something wicked happened resolving 'py.archive.ubuntu.com:http' (-5 - No address associated with hostname)
Err httpq://py.archive.ubuntu.com/ubuntu/ quantal/main git amd64 1:1.7.10.4-1ubuntu1
   Something wicked happened resolving 'py.archive.ubuntu.com:http' (-5 - No address associated with hostname)
Err httpq://py.archive.ubuntu.com/ubuntu/ quantal/main git-core all 1:1.7.10.4-1ubuntu1
   Something wicked happened resolving 'py.archive.ubuntu.com:http' (-5 - No address associated with hostname)
 Failed to fetch httpq://py.archive.ubuntu.com/ubuntu/pool/main/libe/liberror-perl/liberrorperl_0.17-1_all.deb
   Something wicked happened resolving 'py.archive.ubuntu.com:http' (-5 - No address associated with hostname)
 Failed to fetch httpq://py.archive.ubuntu.com/ubuntu/pool/main/g/gi/git-man_1.7.10.4-1ubuntu1_all.deb
   Something wicked happened resolving 'py.archive.ubuntu.com:http' (-5 - No address associated with hostname)
 Failed to fetch httpq://py.archive.ubuntu.com/ubuntu/pool/main/g/git/git_1.7.10.4-1ubuntu1_amd64.deb
   Something wicked happened resolving 'py.archive.ubuntu.com:http' (-5 - No address associated with hostname)
 Failed to fetch http://py.archive.ubuntu.com/ubuntu/pool/main/g/git/git-core_1.7.10.4-1ubuntu1_all.deb
  Something wicked happened resolving 'py.archive.ubuntu.com:http' (-5 - No address associated with hostname)
E: Unable to fetch some archives, maybe run apt-get update or try with --fix-missing?

我该如何安装git在 Ubuntu 12.10 上?我甚至无法从 Ubuntu 软件中心做到这一点。

提前致谢!

答案1

关闭所有与安装软件有关的程序/窗口,例如 Synaptic、软件中心和终端。

现在您应该删除锁定的文件:

您可以使用以下方式删除锁定文件

sudo rm /var/lib/apt/lists/lock

您可能还需要删除缓存目录中的锁定文件

sudo rm /var/cache/apt/archives/lock 

经过:这个答案

现在你应该打开一个终端并运行:

 sudo apt-get update --fix-missing

现在您可以再次安装所需的一切。
祝您有美好的一天

答案2

您是否设置了静态 IP /etc/networks/interfaces?升级到 Ubuntu 12.04 后,我遇到了类似的问题。问题是 DNS 服务器不再设置/etc/resolv.conf,无论您在其中设置什么,它都会在重新启动时被覆盖。解决方案是添加/etc/networks/interfaces以下内容:

dns-nameservers `<IP address of the DNS server>`
dns-domain `<the name of the domain>`

一个快速解决方法是添加名称服务器在 resolv.conf 中,但它会在您重新启动后消失。

答案3

添加/etc/network/interfaces了以下内容:

auto lo
iface lo inet loopback

auto eth0
iface eth0 inet static
address 192.168.1.205
netmask 255.255.255.0
gateway 192.168.1.1

当我调试时,/etc/resolv.conf名称服务器不存在。因此我添加了以下几行:

nameserver 8.8.8.8
nameserver 192.168.1.1

然后就照做了sudo apt-get update。它就起作用了。

答案4

nano /ect/resolv.conf

删除所有

添加

“名称服务器 8.8.8.8”

保存并离开。

再次尝试“apt-get update”,它应该可以工作。

相关内容