I installed wkhtmltopdf, by sudo apt-get install wkhtmltopdf. Its version is 0.9.9.

http://wkhtmltopdf.org/downloads.html says its latest stable version is So I download its deb for Ubuntu 14.04.

I want to use apt to install the downloaded deb for reasons stated in https://unix.stackexchange.com/a/159114/674 and related replies, so I move it to /var/cache/apt/archives, but still how can I install it using apt?

$ mv /tmp/wkhtmltox- /var/cache/apt/archives

$ sudo apt-get install wkhtmltox-
Reading package lists... Done
Building dependency tree       
Reading state information... Done
E: Unable to locate package wkhtmltox-
E: Couldn't find any package by regex 'wkhtmltox-'

$ sudo apt-get install wkhtmltox
Reading package lists... Done
Building dependency tree       
Reading state information... Done
E: Unable to locate package wkhtmltox

$ sudo apt-get install wkhtmltopdf still installs the older version. Thanks.

  • Not without creating a repository: askubuntu.com/a/84323/158442. You can get dependencies installed by double-clicking on the package and thus using the Software Centre. – muru May 6 '15 at 12:52
  • Thanks, @muru. Can you also take a look at my related question askubuntu.com/questions/595063/…? do you recommend me to create a repository to solve that problem too? – Tim May 6 '15 at 12:59
  • I don't think creating a repository would solve that problem. – muru May 6 '15 at 13:05
  • Visit offline repository method of this question. Or APT offline repository method for installing package by apt may help you – Pandya May 12 '15 at 13:55
  • @Tim And why Unable to locate package? : This can help you. – Pandya May 12 '15 at 14:02

Quick Summary

To install a manually downloaded .deb package and also automatically download and install the packages it depends on from your configured repositories:

  • You can run sudo apt-get -f install after installing your .deb with dpkg -i.
  • Or use gdebi to install a .deb package and automatically resolve its dependencies (apt-get will not do this, but gdebi and its graphical frontends will).

See below for details.

Why apt-get Won't Do This

apt-get checks your configured software sources (repositories) and automatically downloads and installs packages. Except in the case where a configured repository is inaccessible, this does not enable an apt-get install command to succeed that would not otherwise succeed. If the package isn't in one of your repositories, apt-get will not know to install it even if the .deb file happens to be in /var/cache/apt/archives.


  • If you have a package already downloaded, and it is the same package apt-get would automatically download and install, then you can put it /var/cache/apt/archives and apt-get will not have to download it.

  • If you have a package already downloaded which is not the same package apt-get would automatically choose, but which is nonetheless available in a configured repository, then you can put it in /var/cache/apt/archives and force apt-get to attempt to install it instead of the package it prefers. For example:

    sudo apt-get install abiword=3.0.1-1
  • Neither of those situations applies to your case. The specific package version is not provided by any of the configured repositories, because it is instead an alpha testing version from the upstream project's download page. Because you have no repository that provides that version of that package, you cannot install your manually downloaded .deb file with apt-get.

Way 1: Install with dpkg and Resolve Dependencies with apt-get

Fortunately, it doesn't look like you need to install this package with apt-get. It appears your actual goal is

  1. to install the manually downloaded .deb package, which isn't provided by your repos (which dpkg can do, but apt-get cannot), and also
  2. to install any its dependencies that are provided by its repos (which dpkg cannot do, but apt-get can).

You can do this in two separate steps:

  1. Install the package with dpkg.

    sudo dpkg -i wkhtmltox-
  2. That created missing dependencies. apt-get can fix missing dependencies automatically.

    sudo apt-get -f install

    That should also automatically finish configuring the original package. (So you will not likely need to run sudo dpkg --configure -a yourself.)

Way 2: Use gdebi to Both Install and Resolve Dependencies

While apt-get won't attempt to automatically install an arbitrary .deb file and its dependencies, there is a tool made for this purpose: gdebi Install gdebi. From man gdebi:

gdebi lets you install local deb packages resolving and installing its dependencies. apt does the same, but only for remote (http, ftp) located packages.

To use gdebi in a terminal, run gdebi package.deb as root, e.g.:

sudo gdebi wkhtmltox-

gdebi also has graphical frontends. You'll probably want to use gdebi-gtk, the GTK+ frontend:

gksudo gdebi-gtk wkhtmltox-

But if you're running Kubuntu (or otherwise using KDE) you might prefer gdebi-kde, the KDE frontend (provided by the gdebi-kde Install gdebi-kde package):

kdesudo gdebi-kde wkhtmltox-

The graphical frontends may also be called without arguments (e.g., gksudo gdebi-gtk), in which case you may click File > Open to browse for and select the .deb file from within the GUI.

Screenshot of the Open Software Package dialog in gdebi-gtk

| improve this answer | |
  • You don't need gdebi at all. The Software Centre can install dependencies. Just do xdg-open foo.deb – muru May 6 '15 at 14:18
  • 3
    @muru Yes, you're right: one can even run software-center package.deb (or double-click the package to open it in USC, as per your comment on the question). Btw the Software Center warns users about "bad quality" .deb packages, which with alpha software--like in the OP's use case--might be considered either particularly useful or an unnecessary annoyance. ...Overall, the Software Center is a good solution, so I can expand this post--but it might be even better if you were to post a separate answer. – Eliah Kagan May 6 '15 at 14:31
  • nah, one awesome answer >> many fragmented answers. – muru May 6 '15 at 14:54
  • using dpkg --unpack instead of dpkg --install will avoid the warning (and non-zero exit status) from unresolved dependencies. Especially useful when writing robust shell scripts that exit on errors. – Phil Frost Feb 23 '16 at 16:28
  • 1
    @sehe So what happens if a.deb doesn't exist, the user doesn't have permissions, or the filesystem is full? Running apt-get install -f after those errors is the wrong thing, but if you are ignoring all errors with || true, you can't really do the Right Thing, can you? dpkg -i in this case accomplishes the same thing as dpkg --unpack, and then it proceeds to attempt to install the package, which you know will fail (that's why you are running apt-get install -f). With --unpack you avoid the error in the expected case, so you can do the Right Thing with the unexpected errors. – Phil Frost Jan 19 '17 at 18:59

To install a locally stored .deb package use dpkg. Try:

sudo dpkg -i /path/to/your/package.deb

apt takes care of the dependency problems which dpkg can not.

There is an interesting project dpkg-offline which is currently under development. To quote from the README of the project,

This tool will download a set of .deb packages needed to install all of the given <packages-to-download>, with their dependencies satisfied, on an installation done from <base-iso>.

You can check out the development version of the tool here. I did not try it, so don't know how (un)stable it is.

Here is a tutorial from the dev branch in Launchpad on how to install and use dpkg-offline.

Bonus There is going to be a show and tell event on this package in the Ubuntu Online Summit on 2015-05-06 at 15:00.

| improve this answer | |
  • 1
    I was faster :) – A.B. May 6 '15 at 12:53
  • ..and I'll give a +1 for that! :P – Ron May 6 '15 at 12:55
  • 1
    Here's yours :) – A.B. May 6 '15 at 12:57

apt-get can't install a deb package, use dpkg:

sudo dpkg -i wkhtmltox-
| improve this answer | |
  • Thanks. But why did the reply and other replies here unix.stackexchange.com/a/159114/674 recommend me to – Tim May 6 '15 at 12:53
  • apt takes care of the dependency problems which dpkg can not. – Ron May 6 '15 at 12:59
  • @Tim May I quote this sentence from the answer on U&L: "(it will work if the .deb package is present in the apt package list)" – ByteBOT May 6 '15 at 13:04
  • @Byte: How can I make the .deb package present in the apt package list? – Tim May 6 '15 at 13:08
  • @Tim I don't know, but you might want to look here: ubuntuforums.org/showthread.php?t=45885 - otherwise: google is your friend! :D – ByteBOT May 6 '15 at 13:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.