How to install a downloaded .deb file along with its dependencies in a system with an internet connection [duplicate]

Say, I have foo-1.2.3.deb which depends on perl and python, however, running command:

dpkg -i ./foo-1.2.3.deb

won't install these dependencies. So I must apt-get install perl python by hand.

How to make dpkg -i install these dependencies for me automatically?


Solution 1:

After using dpkg, running the following command helped me to install the required dependencies:

sudo apt-get -f install

In all, your terminal should look like this:

$ sudo dpkg -i package_with_unsatisfied_dependencies.deb
dpkg: dependency problems prevent ... 
[additional messages]

$ sudo apt-get -f install
[apt messages]
Setting up [dependency]...
Setting up package_with_unsatisfied_dependencies...

Notice the line about Setting up package_with_unsatisfied_dependencies. This fixes (and completes) the installation of package_with_unsatisfied_dependencies.deb.

Solution 2:

starting with apt 1.1 (available in Xenial (16.04), stretch) apt install also allows local files:

sudo apt install ./foo-1.2.3.deb

So much simpler and cleaner.

See the release announcment