How to Install the Latest HPLIP Driver in Ubuntu 20.04 [Fix Dependency Issue]

Last updated: November 5, 2021

Need the most recent HPLIP to get your HP printer or scanner working in Ubuntu? Here’s how to install guide as well as workaround to fix the python-pyqt5 dependency issue.

HPLIP is an open-source Linux drivers for HP’s inkjet and laser printers. The project is initiated and led by HP Inc. While the package in Ubuntu repositories is always old, you can install the official binary to get new devices support.

However, the most recent releases refuse to install in my Ubuntu 20.04 due to python-pyqt5 dependency issue. If you’re facing with the similar issue, then this tutorial may help!

Download & Install HPLIP in Ubuntu 20.04

1.) Firstly, download the latest binary from the link below. It’s ‘hplip-3.21.10.run‘ at the moment.

2.) Next, add executable permission by pressing Ctrl+Alt+T on keyboard to open terminal. Then run command:

chmod u+x ~/Downloads/hplip*.run

And try to install it via command:

~/Downloads/hplip*.run

Follow the terminal output and answer some questions to start installing the driver.

3.) Fix python-pyqt5 dependency issue.

As I said, it refuse to install in Ubuntu 20.04 because it tries to install old Python 2 binding for Qt5 as dependency in my case.

Thanks to Christoph Mueller, I found it has something to do with python symbolic links.

As you may know, python2 and python3 in /usr/bin are symbolic links. While python2 is python2.7, python3 links to python3.8 (or 3.9 depends on Ubuntu edition), python is not exist out-of-the-box. However, it will be created in some cases and links to either python2 or python3.

And the point is when Python links to Python2, HPLIP will mistakenly try to install Python 2 libraries as dependency.

Until HPLIP fixed the issue, the solution is either remove /usr/bin/python if you don’t need it or make it link to Python3.

Make Python to be Python3:

There are two choices to create symlink for python: install python-is-python3 or use update-alternatives command.

Option 1. Open terminal and run command to install ‘python-is-python3’:

sudo apt install python-is-python3

Option 2. Use ‘update-alternatives’ to choose which to link to. Firstly, add both python2 and python3 as alternatives:

sudo update-alternatives --install /usr/bin/python python /usr/bin/python2 1
sudo update-alternatives --install /usr/bin/python python /usr/bin/python3 2

You can then choose which to use anytime via command:

sudo update-alternatives --config python

Finally, re-do step 2.) to install the HPLIP-*.run file.

4.) Fix make command failed issue:

This seems to be HPLIP 3.21.6 only issue, that it outputs ‘error: make command failed with status code 2‘.

By re-running ‘make’ command from the source folder (see Uninstall section), it tells that “/usr/bin/ld: cannot find -lavahi-core”.

And it can be fixed by installing libavahi-core-dev package via command:

sudo apt install libavahi-core-dev

How to Remove HPLIP from Ubuntu:

While installing HPLIP via step 2.), it extracts the .run package into the source folder. And you can find it in Downloads folder.

NOTE: HPLIP 3.21.10 somehow does not create source folder. Run ~/Downloads/hplip*.run --target ~/Downloads/hplip to generate it manually if required.

The folder contains an uninstall script allows to remove HPLIP from your computer.

To do so, go to the source folder, right-click on blank area and select ‘Open in Terminal’.

Finally, run the uninstall script in pop-up terminal window:

sudo python3 uninstall.py

That’s all.

Twitter

I'm a freelance blogger who started using Ubuntu in 2007 and wishes to share my experiences and some useful tips with Ubuntu beginners and lovers. Please comment to let me know if the tutorial is outdated! And, notify me if you find any typo/grammar/language mistakes. English is not my native language. Contact me via ubuntuhandbook1@gmail.com Buy me a coffee: https://ko-fi.com/ubuntuhandbook1

21 responses to How to Install the Latest HPLIP Driver in Ubuntu 20.04 [Fix Dependency Issue]

  1. This was an immense help, thank you.
    Where you say:
    “Before HPLIP fixed the issue, the solution is either …”
    you maybe meant to say
    “Until HPLIP fixes the issue, the solution is either …”

  2. I’m trying to install HPLIP in ZorinOS 16 (Ubuntu 20.04.3) and it fails because it can’t find cups-devel. I’ve tried to install cups-devel but can’t find it in any repository. Any suggestions?
    Frank

    • Try manually installing the dependencies:

      For the python-pyqt5 dependency issue, see this how to tutorial. Or, you can manually install the dependencies via command:

      sudo apt-get install libcups2 cups libcups2-dev cups-bsd cups-client libcupsimage2-dev libdbus-1-dev build-essential ghostscript openssl libjpeg-dev libsnmp-dev libtool-bin libusb-1.0-0-dev wget python3-pil policykit-1 policykit-1-gnome python3-pyqt5 python3-dbus.mainloop.pyqt5 python-gi-dev python3-dev python3-notify2 python3 python3-reportlab libsane libsane-dev sane-utils xsane libavahi-client-dev libavahi-core-dev

      And compile it from source folder (generated automatically once you run the .run file) via configure, make, sudo make install.

      • Many thanks. I am with Zorin 16. However I still have a problem with python 3.

        Here is what I need:
        MISSING DEPENDENCIES
        ——————–
        Following dependencies are not installed. HPLIP will not work if all REQUIRED dependencies are not installed and some of the HPLIP features will not work if OPTIONAL dependencies are not installed.
        Package-Name Component Required/Optional
        python3-pyqt4-dbus gui_qt4 OPTIONAL
        python3-pyqt4 gui_qt4 REQUIRED
        python3-pyqt5-dbus gui_qt5 OPTIONAL
        python3-pyqt5 gui_qt5 REQUIRED

        Here is what is in the file:
        ~$ ll /usr/bin/python*
        lrwxrwxrwx 1 root root 24 sep 26 02:48 /usr/bin/python -> /etc/alternatives/python*
        lrwxrwxrwx 1 root root 9 sep 3 23:37 /usr/bin/python3 -> python3.8*
        -rwxr-xr-x 1 root root 5490352 jun 2 06:49 /usr/bin/python3.8*
        lrwxrwxrwx 1 root root 33 jun 2 06:49 /usr/bin/python3.8-config -> x86_64-linux-gnu-python3.8-config*
        lrwxrwxrwx 1 root root 16 mar 13 2020 /usr/bin/python3-config -> python3.8-config*
        -rwxr-xr-x 1 root root 384 mar 27 2020 /usr/bin/python3-futurize*
        -rwxr-xr-x 1 root root 388 mar 27 2020 /usr/bin/python3-pasteurize*

        • The .run installer won’t work for ZorinOS 16 since it’s not officially supported. However, you may manually compile it from the source folder which is generated in Downloads folder when you run the “.run” installer. See HERE for details.

  3. Hi Ji
    Thank you for your article.

    I followed your advice as regards python:

    sudo apt install python-is-python3

    This and updated

    chmod u+x ~/Downloads/hplip-3.21.8.run

    allowed the install to go ahead.

    Kind regards
    John

  4. Hello
    I Have trouble with install
    Ubuntu 20.04.3.LTS
    hplip-3.21.10.run

    Python install – ok
    libavahi – ok

    but instal stop run on the :

    RUNNING HPLIP LIBS REMOVE COMMANDS
    sudo apt-get remove libhpmud0 libsane-hpaio printer-driver-postscript-hp

    and circle /-\-/…..

    • Since it didn’t output any error, it may be waiting for some other process to be done… or stuck due to post script. Try running the command manually in terminal to see what’s going on:

      sudo apt-get remove libhpmud0 libsane-hpaio printer-driver-postscript-hp
  5. Matt / Upland, CA., USA December 31, 2021 at 12:11 am

    Thanks for this post and your Nov 2021 update! All worked as described. I run Linux Mint 20.2 and Ubuntu 20.04.3 here. On two machines, the HP Device Manager GUI didn’t pop up after the restart, but that’s easily fixed. The HP .py executables are located in /bin. The Device Manager can be executed by /bin/hp-toolbox, and from there you can pin it to the taskbar or make a “shortcut” to the panel (Mint terminology).

  6. Ji –

    Thank you so much for this concise, complete and very useful assistance and support.

    Ned Evans (experienced but new to Linux)

  7. Hi. I use the official hplip package from the standard repository in Ubuntu 20.04, and this is what did the trick:

    sudo apt install python-is-python3
    sudo hp-setup -i

    The system is a headless server and had been upgraded from 18.04.

  8. /media/robert/900 GB Shared/Users/Shared/Downloads/hplip-3.16.7/base/utils.py:2039: SyntaxWarning: “is” with a literal. Did you mean “==”?
    if weburl is “” or weburl is None:
    Current hplip source directory path has space character in it. Please update path by removing space characters. Example: Change /media/robert/900 GB Shared/Users/Shared/Downloads/hplip-3.16.7.run to /media/robert/900GBShared/Users/Shared/Downloads/hplip-3.16.7.run
    rm: cannot remove ‘../hplip-3.16.7’: Directory not empty

    Obviously code is very immature and buggy. Result is that it will not install on my system.
    Useless.

  9. after years we have the same problems with hplip …. best to use hand write instead of print #!#

  10. HI great install steps , but after installing missing scan driver for HP device. I know only printing.

  11. WHEW! What a mess. When will HP devs be brought to ground for almost making a useful Linux package?

  12. At least the HP dev team should provide us the info about at least one distribution on which each hplip version has been tested to work.

  13. Mirza Asad Moazzam Baig November 2, 2023 at 10:49 pm

    I am facing a problem in HPLIP updating the frameware and plugins on two printers, one HP P1005 and other HP P1102. Every time, it shows the same error in Python. Sometimes it shows an error in printing (Printing Completed). I have OS Ubuntu 23.04 and hplip-3.23.8 in my laptop. Any solution?

    • For the default GNOME desktop, open Settings -> Printers -> click the gear button of your printer -> Printer details. Then, try either ‘Search for Drivers’ or manually choose the driver by clicking ‘Select from Database’.