首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >如何重新安装APT软件包

如何重新安装APT软件包
EN

Ask Ubuntu用户
提问于 2019-08-11 15:46:51
回答 1查看 10.6K关注 0票数 1

How重新安装APT包

大家好。

为了解决我以前的问题,我已经删除了apt package.now的新一期如下。要参考我的上一期,请参考以下链接:

设置python3 3 3-aptdaemon时的SyntaxError

代码语言:javascript
运行
复制
$sudo apt-get update
sudo: apt-get: command not found

ariel@ariel:~$ sudo dpkg -install apt
dpkg: error: unknown option -n

Type dpkg --help for help about installing and deinstalling packages [*];
Use 'apt' or 'aptitude' for user-friendly package management;
Type dpkg -Dhelp for a list of dpkg debug flag values;
Type dpkg --force-help for a list of forcing options;
Type dpkg-deb --help for help about manipulating *.deb files;

Options marked [*] produce a lot of output - pipe it through 'less' or 'more' !

ariel@ariel:~$ sudo dpkg -install apt-get
dpkg: error: unknown option -n

Type dpkg --help for help about installing and deinstalling packages [*];
Use 'apt' or 'aptitude' for user-friendly package management;
Type dpkg -Dhelp for a list of dpkg debug flag values;
Type dpkg --force-help for a list of forcing options;
Type dpkg-deb --help for help about manipulating *.deb files;

Options marked [*] produce a lot of output - pipe it through 'less' or 'more' !

ariel@ariel:~$ sudo dpkg -i *

dpkg: error: archive 'Desktop' is not a regular file

ariel@ariel:~$ sudo dpkg -i *

dpkg: error: archive 'Desktop' is not a regular file

ariel@ariel:~$ wget http://security.ubuntu.com/ubuntu/pool/main/a/apt/apt_1.0.1ubuntu2.17_amd64.deb -O apt.deb
--2019-08-11 21:04:37--  http://security.ubuntu.com/ubuntu/pool/main/a/apt/apt_1.0.1ubuntu2.17_amd64.deb
Resolving security.ubuntu.com (security.ubuntu.com)... 91.189.88.24, 91.189.91.26, 91.189.91.23, ...
Connecting to security.ubuntu.com (security.ubuntu.com)|91.189.88.24|:80... connected.
HTTP request sent, awaiting response... 404 Not Found
2019-08-11 21:04:38 ERROR 404: Not Found.

ariel@ariel:~$ sudo dpkg -i apt.deb

dpkg-deb: error: 'apt.deb' is not a Debian format archive

dpkg: error processing archive apt.deb (--install):
 dpkg-deb --control subprocess returned error exit status 2

Errors were encountered while processing:
 apt.deb

ariel@ariel:~$ pkexec dpkg -i apt.deb

dpkg: error: cannot access archive 'apt.deb': No such file or directory

ariel@ariel:~$ 

在N0rbert的第一解之后:

代码语言:javascript
运行
复制
$ sudo apt-get update

apt-get: error while loading shared libraries: libapt-pkg.so.5.0: cannot open shared object file: No such file or directory

ariel@ariel:~/Downloads$ sudo apt install --reinstall apt-utils ubuntu-minimal ub

apt: error while loading shared libraries: libapt-pkg.so.5.0: cannot open shared object file: No such file or directory

ariel@ariel:~/Downloads$ sudo apt update

apt: error while loading shared libraries: libapt-pkg.so.5.0: cannot open shared object file: No such file or directory

在第二个解决方案之后:

代码语言:javascript
运行
复制
$lsb_release -a

No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 18.04.2 LTS
Release:    18.04
Codename:   bionic

谢谢各位,在安装了库文件之后,它确实起了作用,但是给出了另外两个错误。但我不理解它和它的重要性,正如well.kindly建议,如果你是知道的。这些新错误有什么解决办法吗?

代码语言:javascript
运行
复制
$ wget http://mirrors.kernel.org/ubuntu/pool/main/a/apt/libapt-pkg5.0_1.6.11_amd64.deb

--2019-08-11 23:37:16--  http://mirrors.kernel.org/ubuntu/pool/main/a/apt/libapt-pkg5.0_1.6.11_amd64.deb
Resolving mirrors.kernel.org (mirrors.kernel.org)... 198.145.21.9, 2001:19d0:306:6:0:1994:3:14
Connecting to mirrors.kernel.org (mirrors.kernel.org)|198.145.21.9|:80... connected.
HTTP request sent, awaiting response... 301 Moved Permanently
Location: http://mirrors.edge.kernel.org/ubuntu/pool/main/a/apt/libapt-pkg5.0_1.6.11_amd64.deb [following]
--2019-08-11 23:37:17--  http://mirrors.edge.kernel.org/ubuntu/pool/main/a/apt/libapt-pkg5.0_1.6.11_amd64.deb
Resolving mirrors.edge.kernel.org (mirrors.edge.kernel.org)... 147.75.95.133, 2604:1380:3000:1500::1
Connecting to mirrors.edge.kernel.org (mirrors.edge.kernel.org)|147.75.95.133|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 806284 (787K) [application/octet-stream]
Saving to: ‘libapt-pkg5.0_1.6.11_amd64.deb’

libapt-pkg5.0_1.6.11_amd64.deb      100%[=================================================================>] 787.39K  20.3KB/s    in 43s     

2019-08-11 23:38:01 (18.4 KB/s) - ‘libapt-pkg5.0_1.6.11_amd64.deb’ saved [806284/806284]

$ sudo dpkg -i libapt-pkg5.0_1.6.11_amd64.deb

Selecting previously unselected package libapt-pkg5.0:amd64.
(Reading database ... 182918 files and directories currently installed.)
Preparing to unpack libapt-pkg5.0_1.6.11_amd64.deb ...
Unpacking libapt-pkg5.0:amd64 (1.6.11) ...
Setting up libapt-pkg5.0:amd64 (1.6.11) ...
Processing triggers for libc-bin (2.28-10) ...

$ sudo apt update

Hit:1 http://in.archive.ubuntu.com/ubuntu bionic InRelease
Get:2 http://in.archive.ubuntu.com/ubuntu bionic-updates InRelease [88.7 kB]                                                                 
Get:3 http://in.archive.ubuntu.com/ubuntu bionic-backports InRelease [74.6 kB]                                                               
Hit:4 http://ppa.launchpad.net/diesch/testing/ubuntu bionic InRelease                                    
Get:5 http://in.archive.ubuntu.com/ubuntu bionic-updates/main amd64 DEP-11 Metadata [282 kB]        
Get:6 http://security.ubuntu.com/ubuntu bionic-security InRelease [88.7 kB]                                     
Ign:7 http://ppa.launchpad.net/ubuntu-wine/ppa/ubuntu bionic InRelease                                                      
Get:8 http://in.archive.ubuntu.com/ubuntu bionic-updates/main DEP-11 48x48 Icons [66.7 kB]                                                   
Get:9 http://in.archive.ubuntu.com/ubuntu bionic-updates/main DEP-11 64x64 Icons [138 kB]                                                    
Get:10 http://in.archive.ubuntu.com/ubuntu bionic-updates/universe amd64 DEP-11 Metadata [252 kB]                                            
Err:11 http://ppa.launchpad.net/ubuntu-wine/ppa/ubuntu bionic Release                                                       
  404  Not Found [IP: 91.189.95.83 80]
Get:12 http://in.archive.ubuntu.com/ubuntu bionic-updates/universe DEP-11 48x48 Icons [197 kB]    
Get:13 http://in.archive.ubuntu.com/ubuntu bionic-updates/universe DEP-11 64x64 Icons [438 kB]         
Get:14 http://in.archive.ubuntu.com/ubuntu bionic-updates/multiverse amd64 DEP-11 Metadata [2,464 B]
Get:15 http://in.archive.ubuntu.com/ubuntu bionic-backports/universe amd64 DEP-11 Metadata [7,700 B]
Get:16 http://security.ubuntu.com/ubuntu bionic-security/main amd64 DEP-11 Metadata [22.7 kB] 
Get:17 http://security.ubuntu.com/ubuntu bionic-security/main DEP-11 48x48 Icons [10.4 kB]                             
Get:18 http://security.ubuntu.com/ubuntu bionic-security/main DEP-11 64x64 Icons [31.7 kB]
Get:19 http://security.ubuntu.com/ubuntu bionic-security/universe amd64 DEP-11 Metadata [42.1 kB]
Get:20 http://security.ubuntu.com/ubuntu bionic-security/universe DEP-11 48x48 Icons [16.4 kB]
Get:21 http://security.ubuntu.com/ubuntu bionic-security/universe DEP-11 64x64 Icons [116 kB]
Get:22 http://security.ubuntu.com/ubuntu bionic-security/multiverse amd64 DEP-11 Metadata [2,464 B]

(appstreamcli:6798): GLib-CRITICAL **: 23:39:19.478: g_atomic_ref_count_dec: assertion 'g_atomic_int_get (arc) > 0' failed
Reading package lists... Done
E: The repository 'http://ppa.launchpad.net/ubuntu-wine/ppa/ubuntu bionic Release' does not have a Release file.
N: Updating from such a repository can't be done securely, and is therefore disabled by default.
N: See apt-secure(8) manpage for repository creation and user configuration details.

修复最后一个错误的第四个解决方案:

代码语言:javascript
运行
复制
$ sudo add-apt-repository -r ppa:ubuntu-wine/ppa

sudo: add-apt-repository: command not found

第五种解决办法:

代码语言:javascript
运行
复制
$ sudo apt-get install software-properties-common

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

$ sudo add-apt-repository -r ppa:ubuntu-wine/ppa

sudo: add-apt-repository: command not found

解决方案6:

我已经运行了命令$ sudo apt-get upgrade,它成功地执行而没有返回错误。然后在返回相同error.hence的命令下面运行,重新启动系统,然后在返回相同错误的命令下面运行。

代码语言:javascript
运行
复制
$ sudo apt-get install software-properties-common

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

$ sudo add-apt-repository -r ppa:ubuntu-wine/ppa

sudo: add-apt-repository: command not found

由于它显示了Python 3软件属性的某种依赖性,我怀疑它与我先前提出的问题有关(建立python3-aptdeamon时的语法错误链接),是吗?

第七种解决办法:

在注释框中运行命令后,输出如下:

代码语言:javascript
运行
复制
$ grep -r ubuntu-wine /etc/apt --include="*.list"
/etc/apt/sources.list.d/ubuntu-wine-ubuntu-ppa-bionic.list:deb http://ppa.launchpad.net/ubuntu-wine/ppa/ubuntu bionic main
/etc/apt/sources.list.d/ubuntu-wine-ubuntu-ppa-bionic.list:# deb-src http://ppa.launchpad.net/ubuntu-wine/ppa/ubuntu bionic main
/etc/apt/sources.list.d/ubuntu-wine-ubuntu-ppa-bionic.list:# deb-src http://ppa.launchpad.net/ubuntu-wine/ppa/ubuntu bionic main

解决方案8:

没有重新启动sudo apt-get dist-upgrade就成功地执行了。但是sudo apt-get update在下面返回错误。

代码语言:javascript
运行
复制
$ sudo apt-get update

Hit:1 http://in.archive.ubuntu.com/ubuntu bionic InRelease
Get:2 http://in.archive.ubuntu.com/ubuntu bionic-updates InRelease [88.7 kB]                                                                 
Hit:3 http://ppa.launchpad.net/diesch/testing/ubuntu bionic InRelease                                                                        
Get:4 http://in.archive.ubuntu.com/ubuntu bionic-backports InRelease [74.6 kB]
Get:5 http://security.ubuntu.com/ubuntu bionic-security InRelease [88.7 kB]                                                         
Ign:6 http://ppa.launchpad.net/ubuntu-wine/ppa/ubuntu bionic InRelease                              
Get:7 http://in.archive.ubuntu.com/ubuntu bionic-updates/main amd64 DEP-11 Metadata [282 kB]
Get:8 http://in.archive.ubuntu.com/ubuntu bionic-updates/main DEP-11 48x48 Icons [66.7 kB]                                                   
Get:9 http://in.archive.ubuntu.com/ubuntu bionic-updates/main DEP-11 64x64 Icons [134 kB]                                   
Err:10 http://ppa.launchpad.net/ubuntu-wine/ppa/ubuntu bionic Release                                                      
  404  Not Found [IP: 91.189.95.83 80]
Get:11 http://in.archive.ubuntu.com/ubuntu bionic-updates/universe amd64 DEP-11 Metadata [252 kB]                          
Get:12 http://in.archive.ubuntu.com/ubuntu bionic-updates/universe DEP-11 48x48 Icons [195 kB]        
Get:13 http://in.archive.ubuntu.com/ubuntu bionic-updates/universe DEP-11 64x64 Icons [437 kB]       
Get:14 http://in.archive.ubuntu.com/ubuntu bionic-updates/multiverse amd64 DEP-11 Metadata [2,468 B]
Get:15 http://in.archive.ubuntu.com/ubuntu bionic-backports/universe amd64 DEP-11 Metadata [7,712 B]

(appstreamcli:3027): GLib-CRITICAL **: 00:51:25.846: g_atomic_ref_count_dec: assertion 'g_atomic_int_get (arc) > 0' failed
Reading package lists... Done
E: The repository 'http://ppa.launchpad.net/ubuntu-wine/ppa/ubuntu bionic Release' does not have a Release file.
N: Updating from such a repository can't be done securely, and is therefore disabled by default.
N: See apt-secure(8) manpage for repository creation and user configuration details.

$ sudo apt-get dist-upgrade

Reading package lists... Done
Building dependency tree       
Reading state information... Done
Calculating upgrade... Done
The following packages were automatically installed and are no longer required:
  docbook-xml librarian0 rarian-compat sgml-base sgml-data xml-core
Use 'sudo apt autoremove' to remove them.
The following NEW packages will be installed:
  linux-headers-5.0.0-23 linux-headers-5.0.0-23-generic linux-image-5.0.0-23-generic linux-modules-5.0.0-23-generic
  linux-modules-extra-5.0.0-23-generic
The following packages will be upgraded:
  linux-generic-hwe-18.04 linux-headers-generic-hwe-18.04 linux-image-generic-hwe-18.04
3 upgraded, 5 newly installed, 0 to remove and 0 not upgraded.
Need to get 66.9 MB of archives.
After this operation, 330 MB of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 http://in.archive.ubuntu.com/ubuntu bionic-updates/main amd64 linux-modules-5.0.0-23-generic amd64 5.0.0-23.24~18.04.1 [13.6 MB]
Get:2 http://in.archive.ubuntu.com/ubuntu bionic-updates/main amd64 linux-image-5.0.0-23-generic amd64 5.0.0-23.24~18.04.1 [8,356 kB]        
Get:3 http://in.archive.ubuntu.com/ubuntu bionic-updates/main amd64 linux-modules-extra-5.0.0-23-generic amd64 5.0.0-23.24~18.04.1 [33.1 MB] 
Get:4 http://in.archive.ubuntu.com/ubuntu bionic-updates/main amd64 linux-generic-hwe-18.04 amd64 5.0.0.23.80 [1,884 B]                      
Get:5 http://in.archive.ubuntu.com/ubuntu bionic-updates/main amd64 linux-image-generic-hwe-18.04 amd64 5.0.0.23.80 [2,564 B]                
Get:6 http://in.archive.ubuntu.com/ubuntu bionic-updates/main amd64 linux-headers-5.0.0-23 all 5.0.0-23.24~18.04.1 [10.7 MB]                 
Get:7 http://in.archive.ubuntu.com/ubuntu bionic-updates/main amd64 linux-headers-5.0.0-23-generic amd64 5.0.0-23.24~18.04.1 [1,135 kB]      
Get:8 http://in.archive.ubuntu.com/ubuntu bionic-updates/main amd64 linux-headers-generic-hwe-18.04 amd64 5.0.0.23.80 [2,524 B]              
Fetched 66.9 MB in 55s (1,214 kB/s)                                                                                                          
debconf: delaying package configuration, since apt-utils is not installed
Selecting previously unselected package linux-modules-5.0.0-23-generic.
(Reading database ... 182970 files and directories currently installed.)
Preparing to unpack .../0-linux-modules-5.0.0-23-generic_5.0.0-23.24~18.04.1_amd64.deb ...
Unpacking linux-modules-5.0.0-23-generic (5.0.0-23.24~18.04.1) ...
Selecting previously unselected package linux-image-5.0.0-23-generic.
Preparing to unpack .../1-linux-image-5.0.0-23-generic_5.0.0-23.24~18.04.1_amd64.deb ...
Unpacking linux-image-5.0.0-23-generic (5.0.0-23.24~18.04.1) ...
Selecting previously unselected package linux-modules-extra-5.0.0-23-generic.
Preparing to unpack .../2-linux-modules-extra-5.0.0-23-generic_5.0.0-23.24~18.04.1_amd64.deb ...
Unpacking linux-modules-extra-5.0.0-23-generic (5.0.0-23.24~18.04.1) ...
Preparing to unpack .../3-linux-generic-hwe-18.04_5.0.0.23.80_amd64.deb ...
Unpacking linux-generic-hwe-18.04 (5.0.0.23.80) over (4.18.0.25.74) ...
Preparing to unpack .../4-linux-image-generic-hwe-18.04_5.0.0.23.80_amd64.deb ...
Unpacking linux-image-generic-hwe-18.04 (5.0.0.23.80) over (4.18.0.25.74) ...
Selecting previously unselected package linux-headers-5.0.0-23.
Preparing to unpack .../5-linux-headers-5.0.0-23_5.0.0-23.24~18.04.1_all.deb ...
Unpacking linux-headers-5.0.0-23 (5.0.0-23.24~18.04.1) ...
Selecting previously unselected package linux-headers-5.0.0-23-generic.
Preparing to unpack .../6-linux-headers-5.0.0-23-generic_5.0.0-23.24~18.04.1_amd64.deb ...
Unpacking linux-headers-5.0.0-23-generic (5.0.0-23.24~18.04.1) ...
Preparing to unpack .../7-linux-headers-generic-hwe-18.04_5.0.0.23.80_amd64.deb ...
Unpacking linux-headers-generic-hwe-18.04 (5.0.0.23.80) over (4.18.0.25.74) ...
Setting up linux-headers-5.0.0-23 (5.0.0-23.24~18.04.1) ...
Setting up linux-headers-5.0.0-23-generic (5.0.0-23.24~18.04.1) ...
Setting up linux-modules-5.0.0-23-generic (5.0.0-23.24~18.04.1) ...
Setting up linux-image-5.0.0-23-generic (5.0.0-23.24~18.04.1) ...
I: /vmlinuz.old is now a symlink to boot/vmlinuz-4.18.0-25-generic
I: /initrd.img.old is now a symlink to boot/initrd.img-4.18.0-25-generic
I: /vmlinuz is now a symlink to boot/vmlinuz-5.0.0-23-generic
I: /initrd.img is now a symlink to boot/initrd.img-5.0.0-23-generic
Setting up linux-headers-generic-hwe-18.04 (5.0.0.23.80) ...
Setting up linux-modules-extra-5.0.0-23-generic (5.0.0-23.24~18.04.1) ...
Setting up linux-image-generic-hwe-18.04 (5.0.0.23.80) ...
Setting up linux-generic-hwe-18.04 (5.0.0.23.80) ...
Processing triggers for linux-image-5.0.0-23-generic (5.0.0-23.24~18.04.1) ...
/etc/kernel/postinst.d/initramfs-tools:
update-initramfs: Generating /boot/initrd.img-5.0.0-23-generic
/etc/kernel/postinst.d/zz-update-grub:
Sourcing file `/etc/default/grub'
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-5.0.0-23-generic
Found initrd image: /boot/initrd.img-5.0.0-23-generic
Found linux image: /boot/vmlinuz-4.18.0-25-generic
Found initrd image: /boot/initrd.img-4.18.0-25-generic
Found linux image: /boot/vmlinuz-4.18.0-21-generic
Found initrd image: /boot/initrd.img-4.18.0-21-generic
Adding boot menu entry for EFI firmware configuration
done

解决方案9:

葡萄酒ppa去除成功。

代码语言:javascript
运行
复制
$ sudo rm -v /etc/apt/sources.list.d/ubuntu-wine-ubuntu-ppa-bionic.list
removed '/etc/apt/sources.list.d/ubuntu-wine-ubuntu-ppa-bionic.list'

解决方案10:sudo apt update成功执行而不返回错误。

代码语言:javascript
运行
复制
$sudo apt update

Hit:1 http://in.archive.ubuntu.com/ubuntu bionic InRelease
Hit:2 http://in.archive.ubuntu.com/ubuntu bionic-updates InRelease                                                                           
Hit:3 http://in.archive.ubuntu.com/ubuntu bionic-backports InRelease                                                                         
Hit:4 http://ppa.launchpad.net/diesch/testing/ubuntu bionic InRelease                                                           
Get:5 http://security.ubuntu.com/ubuntu bionic-security InRelease [88.7 kB]                            
Fetched 88.7 kB in 2s (40.2 kB/s)                             
Reading package lists... Done
Building dependency tree       
Reading state information... Done
All packages are up to date.
EN

回答 1

Ask Ubuntu用户

发布于 2019-08-11 16:07:48

请确保您的设备已连接到互联网,并手动下载apt/apt-get's 套餐,并将其安装在较低级别上:

代码语言:javascript
运行
复制
cd ~/Downloads
wget http://mirrors.kernel.org/ubuntu/pool/main/a/apt/apt_1.6.11_amd64.deb
sudo dpkg -i apt_1.6.11_amd64.deb

libapt-pkg.so.5.0库重新安装包:

代码语言:javascript
运行
复制
wget http://mirrors.kernel.org/ubuntu/pool/main/a/apt/libapt-pkg5.0_1.6.11_amd64.deb
sudo dpkg -i libapt-pkg5.0_1.6.11_amd64.deb

然后像往常一样使用APT:

代码语言:javascript
运行
复制
sudo apt-get update
sudo apt-get upgrade

要用葡萄酒PPA修复最后一个错误,只需使用以下方法删除:

代码语言:javascript
运行
复制
sudo rm /etc/apt/sources.list.d/ubuntu-wine-ubuntu-ppa-bionic.list

然后安装所有新的依赖项

代码语言:javascript
运行
复制
sudo apt-get update
sudo apt-get dist-upgrade
票数 4
EN
页面原文内容由Ask Ubuntu提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://askubuntu.com/questions/1165003

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档