It’s one of the common error thrown by dpkg
package manager:
Step 1: First thing a package manager does is configure package database, which contains installed packages information. If a package installation is interrupted, then this database may have become corrupt. So let’s reconfigure the package database.
Re-configure Package Database
Execute the below command to repair and reconfigure the package database:
# sudo dpkg --configure -a
Step 2: Some of the packages may be cached, because of which the installation may be interrupted.
Install forcefully
Execute the below command to install a package forcefully:
# sudo apt-get install -f <package-name>
Step 3: Remove unwanted packages installed previously which might be affecting the package installation.
Auto-remove unwanted packages
Execute the below command to remove unwanted packages installed previously. This is a safe command which will clean cache for unused packages.
# sudo apt-get autoremove
That’s it.