Let's assume that one has some modern HP printer and/or scanner which is not supported by HPLIP package from official repository.
Currently Ubuntu versions have the following versions in universe pocket:
bionic (18.04LTS): 3.17.10+repack0-5 focal (20.04LTS): 3.20.3+dfsg0-2 impish (21.10): 3.21.6+dfsg0-0ubuntu1
What can one do if printer is supported in newer version of HPLIP (checked this in HP Developer Portal | All Supported Printer Models)?
Installation
Currently there are no PPAs with newer
hplip
packages.But user can download and install binary from HP as described in their manual.
Before you proceed you should remove any
hplip
related packages to avoid possible future conflicts.If your system is a recent Debian (11 bullseye and newer) Ubuntu (20.04 LTS focal and newer), you should check for python2 legacy support installed (see below "Incompatibility with python2 legacy support on recent Debian and Ubuntu")
HP have note about this problem on support page:
I have experimentally determined the list of packages (tested on 16.04 LTS, 18.04 LTS, 20.04 LTS and 21.04) and below are commands:
Then you should perform the following steps:
Step 1: Download the Automatic Installer (.run file) from official link for the Ubuntu or as for today using
wget
Step 2: Run the Automatic Installer
Then follow instructions on screen (it should ask password of your
sudo
-capable user to runapt
, and removehplip-gui
files if they were installed). The installation process is already well-documented on HPLIP site.After installation it will show printer installation wizard and you can add printer to the system.
Uninstallation
Here we start with binary HPLIP installation (so we do not have HPLIP-related deb-packages installed).
Let's consider that we have completed installation using file
hplip-3.22.2.run
(or other version). We need to call special uninstallation script as follows:Afterwards we install official Ubuntu packages instead (optionally):
Note: I have reported bug 1782137 to HPLIP's LaunchPad account asking developers to include uninstallation feature of deb-packages HPLIP components from Ubuntu.
Incompatibility with python2 legacy support on recent Debian and Ubuntu
Python2 is deprecated since Debian 11 (bullseye) and Ubuntu 20.04 LTS (focal) so many old python packages don't exist any more. Plus packages must explicitly refer to either
python3
orpython2
notpython
. For compatibility with legacy python2 code using/usr/bin/python
, two packagespython-is-python2
andpython-dev-is-python2
may already be installed on your system. They just install some links sopython
andpython-config
point to the python2 version of these commands.You need that for instance to run the color calibration suite DisplayCal (displaycal 3.8 still relies on python2 code).
The easiest way to check is to run
python --version
and see if it's python version 2 or version 3.If you run the hplip install package, it will fail because it tries to find which version of python is to be used (probably by something based on
python --version
or equivalent). If you have the python2 compatibility packages installed, the scrip is fooled and tries to install python2 dependency packages that are no longer available.If you really need to install hplip from HP site, and you really need python2 based tools, you can always change temporarily the link on python version :
Then run the installer.
When everything is installed edit the
/usr/share/hplip/*.py
python files to replace first line (#!/usr/bin/env python
) by#!/usr/bin/python3
as it is in debian and ubuntu hplip packages.Until a few weeks ago, the latest HPLIP driver version, available at HP Developers - HP Linux Imaging and Printing, was 3.18.12. At Ubuntu 16.04 official repository, the available version was 3.16.3.
First I tried to install the latest version, downloaded from the website. However, a compatibility issue raised with the package
python-gobject
. As noted by N0rbert (main answer), you need to completely uninstall the actual version of HPLIP before you install another version. Do it manually, as described by N0rbert. After that, ensure that the following files are not present any more (or that the respective folders are empty):I am not sure if all the files listed above absolutely need to be removed. However, with them gone, I could proceed with the new installation without problems.
Although the repo doesn't have the latest version of the driver, I decided to install it, via
apt
, because it works without crashing with other preinstalled packages. I did as follows:sudo apt install hplip
(Linux driver for most HP's printers and scanners).sudo apt install hplip-gui
(required by hp-plugin).hp-plugin
(as normal user).This plugin is a proprietary "part" of the driver which HP doesn't open-source. The device won't work without it. You will be prompted to accept the terms and install the required plugin for the exact version of the driver you have installed.
hp-doctor
(to ensure everything is installed properly, especially the plugin).hp-setup
to add the connected device, or use the HP's software (with graphical interface), already installed at this point.Go to Ubuntu System Settings and add a new printer/scanner with HPLIP.
PS: By January 2019, the latest version is 3.19.1, which I have not tested.
In general, if you don't really need the latest version of a package, prefer installing the one offered at the official repository. It's much more likely you won't have problems afterwards.
If you are on Ubuntu 20.04
Then Restart the computer !!
After my old printer from another brand refused to print after about 15 years I tried to install an HP M182n today. I thought that HP drivers were among the best in class, starting with my old 18.04 installation I hit some road blocks which I'm going to list here.
The easy route for my case would have been to use Ubuntu 20.04 with default packages. So in doubt try that first before you loose a lot of time.
Moving on:
There is a snap which apparently was a summer mentoring project but never left experimental stage, yet it shows up in search results in the software center when searching for HPLIP which many people seem to do instead of opening a terminal, it's Ubuntu after all. Snap version 0.2 from August 2019 doesn't appear to work at all. The description only slightly hints that it is non-functional software.
Since my model is a multi-function printer with a scanner I need to install HPLIP plugins, the easiest way to do that seems to be
hp-plugin
as Felipe and others wrote. You can also download it from the HP site, but that is to messy for my taste.Noteworthy: If you haven't had a network printer/MFP before and you think that a firewall may be a problem due to a connection time out be sure to install the HPLIP plugin first before chasing after other things and disabling a lot of security features out of frustration.
Finally, if you absolutely have to download the latest version from the HP site, be sure to check that it is the latest version you are downloading. GitHub has an API, and today I learned that Sourceforge has one too! Let's use that and don't write instructions with hard coded version numbers you have to keep track of.
Installing HPLIP 3.20.9 got me into more trouble on Ubuntu 20.04 since it has some broken dependencies. https://bugs.launchpad.net/hplip/+bug/1878974/comments/8
As I said, my setup works for now and I have to make I jump from lightly dumb mfp printers to new network printers.
Edit: Trying to install the plugin got me into more trouble on 18.04. It seems like HP has removed the plugin with the matching version in Ubuntu in favor of a minor version bump… and nobody gave it a second thought. I've opened a bug to hopefully get this resolved: https://bugs.launchpad.net/ubuntu/+source/hplip/+bug/1903693