How to install latest HPLIP on my Ubuntu to support my HP printer and/or scanner?

69,281

Solution 1

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:

Warning: If you are upgrading HPLIP and HPLIP is already preinstalled with your distribution, or you if you installed HPLIP using an RPM, DEB, or other package, please uninstall the previous version using the method specific for your distribution. If you do not do this, you may have package conflict issues or functionality problems.

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:

sudo apt-get purge hplip hplip-data hplip-doc hplip-gui hpijs-ppds \
libsane-hpaio printer-driver-hpcups printer-driver-hpijs
sudo rm -rf /usr/share/hplip/

sudo apt-get autoremove

Then you should perform the following steps:

  1. Step 1: Download the Automatic Installer (.run file) from official link for the Ubuntu or as for today using wget

    wget -c  https://download.sourceforge.net/project/hplip/hplip/3.22.2/hplip-3.22.2.run
    
  2. Step 2: Run the Automatic Installer

    sh hplip-3.22.2.run
    

    Then follow instructions on screen (it should ask password of your sudo-capable user to run apt, and remove hplip-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:

sudo hp-uninstall
sudo rm -vrf /usr/share/hplip/ 
sudo rm -vrf /root/.hplip
sudo rm -v /usr/share/hal/fdi/preprobe/10osvendor/20-hplip-devices.fdi

Afterwards we install official Ubuntu packages instead (optionally):

sudo apt-get -o Dpkg::Options::="--force-confask" install --reinstall hplip hplip-data hplip-doc hplip-gui libsane-hpaio

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 or python2 not python. For compatibility with legacy python2 code using /usr/bin/python, two packages python-is-python2 and python-dev-is-python2 may already be installed on your system. They just install some links so python and python-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 :

sudo apt-get install python-is-python3 python-dev-is-python3

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.

Solution 2

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):

/etc/hp/hplip.conf
/var/lib/hp/hplip.state
/usr/share/hplip/
/usr/share/ppd/hplip
~/.hplip/hplip.conf
/etc/cups/ppd/HP-....ppd

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:

  1. sudo apt install hplip (Linux driver for most HP's printers and scanners).

  2. sudo apt install hplip-gui (required by hp-plugin).

  3. 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.

  4. hp-doctor (to ensure everything is installed properly, especially the plugin).

  5. hp-setup to add the connected device, or use the HP's software (with graphical interface), already installed at this point.

  6. 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.

Solution 3

If you are on Ubuntu 20.04

sudo apt install hplip hplip-gui

Then Restart the computer !!

Note: Remove all kinds of the previous installation first. See this answer.

Solution 4

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.

    # Download latest release using the Sourceforge release API
    # Notes:
    # - Linux platform is still tagged to offer 3.16 release from 2016.
    # - The parts of the URL are replaced to yield a result similar to this:
    #   https://nchc.dl.sourceforge.net/project/hplip/hplip/3.20.9/hplip-3.20.9.run
    # https://sourceforge.net/p/forge/documentation/Using%20the%20Release%20API/
    
    wget $(curl https://sourceforge.net/projects/hplip/best_release.json \
           | jq -r '.platform_releases.windows.url' \
           | sed -e '{s/tar\.gz.*/run/;s/downloads/nchc.dl/}')
    

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

Share:
69,281

Related videos on Youtube

N0rbert
Author by

N0rbert

Updated on September 18, 2022

Comments

  • N0rbert
    N0rbert almost 2 years

    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)?

  • Mookey
    Mookey over 5 years
    This helped me get rid of a dependency issue with python. THank you.
  • jerome
    jerome over 5 years
    This was a great solution for Ubuntu 18.04 as well. The older version of this package from the official repository, and of hp-doctor do state that the distro is not yet supported, but the entire process worked very well for me, as compared to the 3.19.1 version, which I could not get to work due to a python2/python3 dependency mismatch during the hp-setup and hp-plugin commands.
  • Dr Xorile
    Dr Xorile over 5 years
    So sudo apt install hplib-gui definitely seems to work better than downloading and running (I got "no systemtrayicon available" and "Failed to load module 'canberra-gtk-module'"). But how do you then run it? I used to have an icon that appeared on my tool bar.
  • N0rbert
    N0rbert over 5 years
    @DrXorile tray behavior depends on your desktop environment. With GNOME it may fail, but with MATE it will work. You can run HPLIP with hp-toolbox. Binary installation is needed only if your device requires the newest HPLIP version.
  • KiriSakow
    KiriSakow about 5 years
    For those like myself who have Ubuntu 18.04 with multiple python2 and python3 versions managed by the update-alternatives tool (check here if you wish to learn more), running hp-doctor and hp-setup commands may not work with the error: cupsext could not be loaded. please check hplip installation message printed out in response. Solution: run python3 $(which hp-doctor) and python3 $(which hp-setup) commands instead.
  • Sadi
    Sadi almost 5 years
    @KiriSakow It seems the best solution for my HP LaserJet is the hplip package in the official repositories of Ubuntu 18.04. I just works - without some problems I have with the latest one from HP. However, things like hp-setup, hp-doctor, hp-systray won't work (although not so important) even with the solution you suggest - I get the same python error messages although python3 is installed. Do you think I'm missing something?
  • matanster
    matanster almost 5 years
    fails with an error about the dependencies for me: askubuntu.com/questions/1173641/installing-hplip-3-19-8-fail‌​s
  • matanster
    matanster almost 5 years
    Step 6 is already taken care of by step 5 in my case.
  • matanster
    matanster almost 5 years
    This answer is very important because it includes the hp plugin step, which seems to be required for things to actually work.
  • jerome
    jerome over 4 years
    Confirming these steps (mostly) work for me on Ubuntu 19.10. (Mostly, in that hp-doctor gives an error error: cupsext not present in the system. Please re-install HPLIP. - but printer selection and printing works just fine.)
  • Zeta.Investigator
    Zeta.Investigator over 4 years
    What to do with all those sudo pip2 installs that the .run script has done? It has loaded lots of python2 dependencies on system level like opencv-python, skit-image,... Why the script invoked the sudo pip install and polluted the system?
  • Duncan
    Duncan about 4 years
    Something strange here. I have a pc and a laptop and on both of them upgraded from Ubuntu 18.04 to 20.04. The printing facility on the laptop is perfect but I can't get it to work on my pc. Irritating! Can anyone suggest what I can do to find out what is right about the situation on my laptop so that I can fix my pc?
  • matanster
    matanster almost 4 years
    "error: debian-bullseye/sid version is not supported, so all dependencies may not be installed. However trying to install using debian-10.3 version packages". Then it refuses to accept the sudo password. This is a nightmare I wonder if other brands work better.
  • N0rbert
    N0rbert almost 4 years
    @matanster Debian is off-topic here, but if Ubuntu was wrongly detected as Debian - then see this Q&A.
  • Csabi Vidó
    Csabi Vidó over 3 years
    @N0rbert Hello, I read through your answer and others while trying to set up my new printer today. I posted my own (temporary) answer with my findings. I think there could be something improved with the existing answers, particularly the hard coded version numbers could be avoided and some other misconceptions. For the moment I'm using the version from the archvies in 20.04. 18.04 would not work for me at all but I think that effort on my side is better spend moving forward. Let me know what you think about the download command in my post, it was written in a hurry and could be improved.
  • Adam
    Adam almost 3 years
  • ChrisAga
    ChrisAga over 2 years
    Doesn't work for 21.04 since hplip-3.21.8.run insists on installing python-pyqt5 , python-dbus, python-dbus.mainloop.pyqt5, python-notify, python-reportlab, python-gobject which don't exist. These packages have a python3-____ counterpart except for python-gobject. THose counterparts are installed but the scrip fails on pyqt5 dbus. This script is not 21.04 Hirsute Hippo compatible !
  • ChrisAga
    ChrisAga over 2 years
    After more investigations, it appears that hplip-3.21.8.run seems to be both python2 and python3 compatible. Python2 is deprecated in ubuntu 21.04 but two compatibility packages are installed python-is-python2 and python-dev-is-python2 respectively to link /usr/bin/python to /usr/bin/python2 and /usr/bin/python-config to python2 default. If possible uninstall those two packages. If not you can fool hplip-3.21.8.run by changing the version of python /usr/bin/python is pointing to, but beware that hplip tools won't work if you come back to python2. hplip should use python3.
  • N0rbert
    N0rbert over 2 years
    @ChrisAga thanks, it really fails with Python2 set as default. Answer is now updated to prevent such behavior. Thanks again.
  • ChrisAga
    ChrisAga over 2 years
    @N0rbert. I proposed a paragraph on how to understand and may be deal with the problem hopping it could help those who are stuck with tools still running python2 code.
  • Mr.Gosh
    Mr.Gosh over 2 years
    doesn't work on my ubuntu 20.04 machine. error: /home/user/.local/lib/python3.8/site-packages/PyQt5/QtCore.a‌​bi3.so: failed to map segment from shared object and than error: Unable to load Qt4/Qt5 support. Is it installed? even after isntall pythonispython3 - can't get it to work again. Interactive setup of the printer works bit trying to scan for example produces an error: /home/user/.local/lib/python3.8/site-packages/PyQt5/QtWidget‌​s.abi3.so: failed to map segment from shared object
  • N0rbert
    N0rbert over 2 years
    @Mr.Gosh and what? Please remove your locally installed Python stuff first and then retry.
  • Mr.Gosh
    Mr.Gosh over 2 years
    OK - was not aware there was something isntalled by hand from me. But you are right - that was the Problem. You realized that cause pf the links in /home/... ?