树莓派升级失败

时间:2020-12-28 16:06:11

标签: raspberry-pi

当我尝试在 raspberry pi 上升级或更新 raspberry pi 或 python 时,出现此错误

pi@raspberry:/$ sudo apt-get install python
sudo: unable to resolve host raspberry: Name or service not known
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
  ***
Suggested packages:
  ***
0 upgraded, 101 newly installed, 0 to remove and 0 not upgraded.
Need to get 4,560 kB/33.3 MB of archives.
After this operation, 104 MB of additional disk space will be used.
Do you want to continue? [Y/n] Y
Get:1 http://mirror.as43289.net/raspbian/raspbian buster/main armhf libpython2.7-minimal armhf 2.7.16-2+deb10u1 [395 kB]
Get:2 http://mirror.as43289.net/raspbian/raspbian buster/main armhf python2.7-minimal armhf 2.7.16-2+deb10u1 [1,091 kB]
Get:3 http://mirror.as43289.net/raspbian/raspbian buster/main armhf python2-minimal armhf 2.7.16-1 [41.4 kB]
Get:4 http://mirror.as43289.net/raspbian/raspbian buster/main armhf python-minimal armhf 2.7.16-1 [21.0 kB]
Get:5 http://mirror.as43289.net/raspbian/raspbian buster/main armhf mime-support all 3.62 [37.2 kB]
Get:6 http://mirror.as43289.net/raspbian/raspbian buster/main armhf libexpat1 armhf 2.2.6-2+deb10u1 [77.3 kB]
Get:7 http://mirror.as43289.net/raspbian/raspbian buster/main armhf libpython2.7-stdlib armhf 2.7.16-2+deb10u1 [1,844 kB]
Get:8 http://mirror.as43289.net/raspbian/raspbian buster/main armhf python2.7 armhf 2.7.16-2+deb10u1 [305 kB]
Get:9 http://mirror.as43289.net/raspbian/raspbian buster/main armhf libpython2-stdlib armhf 2.7.16-1 [20.8 kB]
Get:10 http://mirror.as43289.net/raspbian/raspbian buster/main armhf libpython-stdlib armhf 2.7.16-1 [20.8 kB]
Get:11 http://mirror.as43289.net/raspbian/raspbian buster/main armhf python2 armhf 2.7.16-1 [41.6 kB]
Get:12 http://mirror.as43289.net/raspbian/raspbian buster/main armhf python armhf 2.7.16-1 [22.8 kB]
Get:13 http://mirror.as43289.net/raspbian/raspbian buster/main armhf bzip2 armhf 1.0.6-9.2~deb10u1 [46.2 kB]
Get:14 http://mirror.as43289.net/raspbian/raspbian buster/main armhf libmagic-mgc armhf 1:5.35-4+deb10u1 [242 kB]
Get:15 http://mirror.as43289.net/raspbian/raspbian buster/main armhf libmagic1 armhf 1:5.35-4+deb10u1 [110 kB]
Get:16 http://mirror.as43289.net/raspbian/raspbian buster/main armhf file armhf 1:5.35-4+deb10u1 [65.4 kB]
Get:17 http://mirror.as43289.net/raspbian/raspbian buster/main armhf xz-utils armhf 5.2.4-1 [179 kB]
Fetched 4,560 kB in 21s (219 kB/s)
E: Cannot get debconf version. Is debconf installed?
debconf: apt-extracttemplates failed: No such file or directory
Extracting templates from packages: 29%E: Cannot get debconf version. Is debconf installed?
debconf: apt-extracttemplates failed: No such file or directory
Extracting templates from packages: 59%E: Cannot get debconf version. Is debconf installed?
debconf: apt-extracttemplates failed: No such file or directory
Extracting templates from packages: 89%E: Cannot get debconf version. Is debconf installed?
debconf: apt-extracttemplates failed: No such file or directory
Extracting templates from packages: 100%
dpkg: error: parsing file '/var/lib/dpkg/status' near line 0:
 newline in field name '▒PNG'
E: Sub-process /usr/bin/dpkg returned an error code (2)

我一开始就使用这个代码。但是对于每一个我都遇到了相同的错误,错误代码 (2)

sudo apt-get upgrade
sudo apt-get update
sudo apt-get install python

我使用的是 Raspberry pi 1 版本。这是我知道的旧版本,但我必须使用它。 请帮帮我。谢谢大家。

2 个答案:

答案 0 :(得分:0)

您似乎没有在 /etc/hosts 文件中正确设置主机。为了修复它,您应该将 raspberry 添加到同一个文件中。您可以通过创建 sudo nano /etc/hosts 并在 127.0.1.1 地址之后您已有的用户名旁边添加此用户名来实现此目的。不是在单词 localhost 之后(您肯定必须编辑第二行)。

答案 1 :(得分:0)

sudo apt-get update
sudo apt-get upgrade -y

升级时会失败。因为这个命令再次更新sources.list。因此,它显示此错误。您可以再次运行 sudo apt-get update && sudo apt-get upgrade -y。没关系。