How to Install HP Printer in Ubuntu 18.04

I need to install a Color LaserJet Pro MFP M277dw printer on USB on a new desktop, which worked great with HPLIP on previous vers, but doesn't work with Ubuntu 18.04.

  1. Ubuntu comes with HPLIP 3.17 but it doesn't detect my printer. Using pkg mgr, I uninstalled & reinstalled it, installed missing dep, still failed.
  2. Reinstalled ubuntu 18.04, followed How to install latest HPLIP on my Ubuntu to support my HP printer and/or scanner? exactly, and got Failed to load module "canberra-gtk-module", and No systemtrayicon available, and printer not detected trying to install it:

    error: No device selected/specified or that supports this functionality.
    error: hp-setup failed. Please run hp-setup manually.
    

Note HPLIP 3.15.4 added my printer.


Solution 1:

1. Make sure you have several python (aka python2) and python3 versions installed.

Check this thread if you wish to learn more.

2. Completely uninstall HPLIP,

as explained here and here.

3. Install HPLIP and its dependencies from Ubuntu 18.04 repository

At the time of writing it is HPLIP 3.17.10.

sudo apt install hplip hplip-gui hplip-data hplip-doc hpijs-ppds libsane-hpaio printer-driver-hpcups printer-driver-hpijs

4. Run hp-doctor with python3

For those like myself, running hp-doctor and hp-setup commands alone may not work with the error: cupsext could not be loaded. please check hplip installation message printed out in response; you need to specify python version and point at where the respective binary files are located using which command:

python3 $(which hp-doctor)

Make sure nothing is missing; everything should have OK status.

5. Run hp-setup with python3

python3 $(which hp-setup)

Follow the steps.