Installing HPLIP 3.10.6 on CentOS 5.3

As versions change, this page will probably quickly become obsolete, (On the other hand, RedHat still, as of January, 2015, hasn't completely figured out the dependencies for hplip, so maybe not.)

however, the question seems to come up very frequently. Part of this is because the hplip documentation is lacking, or perhaps outdated. Most of it is correct, but there are some things that seem to throw people.

NOTE: The rpmforge repo has updated packages available, which may make this entire page unnecessary. (The latest, as of July 31, 2010, is hplip-3.10.6-0.1.) Note that this is, as of July 31st, 2010, in rpmforge testing. My own experience was that using it, rather than the tarball as detailed below, worked for printing but not scanning, so at present, I'm still recommending that the reader with a multifunction use the tarball.

UPDATE: It seems that as mentioned in this bug, that the problem is that the hplip rpms for RH based distributions doesn't include a requirement for libsane-hpaio. Therefore, I'd recommend that the user first try Dag's latest version, and if it doesn't scan, then install libsane-hpaio, and see if that solves the problem. I've found that in Fedora and Scientific Linux 6, based on RH 6, it does fix the problem. Fedora at least is working on changing this, judging from the bug linked above. However, as of January 3, 2015, it still exists, and these days, I don't use Fedora enough to bother updating it.

Speaking of Fedora (and this is probably true for CentOS/RHEL as well), when running hp-setup (as explained below), be sure that cups is running. Otherwise, it will tell you there is no ppd file for that printer. If cups is running, then when hplip discovers the printer, it will build the ppd. (It will also find the ppd if the printer has been installed previously, either using cups or one of the desktop environments' printer configuration tools.

(Note that this applies to using hplip provided by rpm. If installing the source from hplipopensource.com, the ppd file will be provided, as explained below.)

Again, as of January 2015, this wasn't true for Fedora 21. I had to first install the printer via cups for hp-setup to be able to get a ppd. Again, I don't, at this time, use Fedora enough to take more time investigating but on at least one install, I first had to add the printer via cups to create the ppd and also had to add the libsane-hpaio. In fairness, Fedora's default Gnome installs probably have this as an unneeded dependency. (Sorry, I'm in a grouchy mood as I write this.)

The version of hplip that comes with CentOS is rather old. Many of the current printers, especially the all-in-ones, require a later version to work properly.

Note that despite the instructions on their page, I have not been able to get hp-setup's graphic mode working, as it seems to have trouble with finding PyQt4. This isn't essential to me, so I haven't deeply investigated it. This lack of PyQt4 also means, however, that hp-tools won't work.

You will be able to setup your printer, however, using hp-setup -i rather than hp-setup.

Go to the HPLIP CentOS page. As they say, you will need root access to do much of this, so either use root or sudo. If using sudo, keep in mind that only root has access to /sbin and /usr/sbin, so you will have to add those to your $PATH. If using su, you will probably have to use su - to get the path. For more explanation, see my page on this.

HPLIP suggests installing the entire development tools group. This is probably unnecessary, but at time of writing, I haven't figured out exactly what is and isn't needed, so do it.
yum -y groupinstall 'Development Tools'

Next they give a list of packages that are required dependencies. Cutting and pasting from their page almost works. :) However, there are several errors and omissions. They have the names pyqt and pyqt-devel. Use PyQt and PyQt-devel. They also leave out openssl-devel. For whatever reason, if you don't install that, when you run the configure script, it will fail to find net-snmp support, even though the net-snmp packages might be installed. Installing openssl-devel will fix this problem.

They also leave off cups and ghostscript. Though hplip will build and install without them, you can't do much without either one, unless you're only going to use it as a scanner. If using sudo, or if you've already done su to root, you can also leave out the su -c and quotes. This should all be on one line.
su -c "yum install xsane cups-devel libjpeg-devel python-devel PyQt
PyQt-devel net-snmp-devel net-snmp-utils libusb-devel
sane-backends-devel dbus-devel python-imaging openssl-devel cups
ghostscript"

The site says to disable selinux. On at least one machine (running Scientific Linux Alpha, similar to RHEL6, I haven't found this to be necessary.

I would say, if you use selinux, leave it on and see if it works anyway. There are hundreds of debates about the value vs. inconvenience (and performance hit) of selinux, and it's well beyond the scope of this article. If you choose to disable it, the method they give, of editing /etc/sysconfig/selinux, is permanent and requires a reboot. To temporarily disable it
setenforce 0

If you are following their page, you will note that I have skipped the step of symlinking libcrypto. I haven't found it necessary. It certainly won't hurt if you want to do it.

Download the regular tarball from the link provided on their page. Once it's done
tar xvf hplip-<version>.tar.gz

It is version 3.9.8 at time of writing. We'll use that version in the next step.

We'll change into the directory and run the configure script. Their page gives recommendations for both 32 bit and 64 bit installations. You can use that, or run configure --help to see all the options. I use their script, save to change --enable-fax-build to --disable-fax-build as my all in one doesn't have a fax. In the example below, however, I'll simply cut and paste their example for a 64 bit build. Again, it should all be on one line, and this part doesn't need to be done as root.

NOTE: In this version, I enable dbus. Dag Wieers, of rpmforge fame, has found that this can cause errors due to some incompatibilities, such as
error: Unable to load dbus - Automatic status updates in HPLIP Device
Manager will be disabled.

I don't use the device manager, so haven't run into that. Most users, however, should probably change what I have below to disable dbus.
cd hplip-3.9.8
./configure --with-hpppddir=/usr/share/ppd/HP --libdir=/usr/lib64
--prefix=/usr --enable-qt4 --enable-doc-build --enable-cups-ppd-install
--disable-foomatic-drv-install --disable-foomatic-ppd-install
--disable-hpijs-install --disable-policykit --disable-cups-drv-install
--enable-hpcups-install --enable-network-build --enable-dbus-build
--enable-scan-build --enable-fax-build

When this is done, run make. You don't have to be root.
make

Now as root
make install

Once this is done, you can run hp-setup -i. Note the -i.

If you just run hp-setup you'll get an error about PyQt4. They will suggest either running hp-setup -i or running with --qt3. However, if you try running --qt3, you will get an error that it's an unknown option. Oh well.

Before running the command, make sure that cups is running.
service cups start

If it's a networked printer, I would also use the IP address of the printer as well. For example, if the printer is at 192.168.1.120
hp-setup -i 192.168.1.120

It should find the printer. At that point, you can use the name they suggest or change it. If using their name, as they tell you in the instructions, you can just type m. Next, it will search for a ppd file, which it may or may not find. If it doesn't find it, it will ask if you want to specify the path. Hit y for yes.

See if the ppd is actually there in /usr/share/ppd/HP. If so, you can manually specify the path. If it isn't, then copy it over. The tarball, if your printer is supported, contains a directory called ppd. This contains two subdirectories, hpcups and hpijs. I always use the ppd from cups, as for whatever reason, at least with my C4795, the one from hpijs didn't work well. So, if HPLIP doesn't find the ppd, and said ppd file isn't in /usr/share/ppd/HP copy it from the hplip-3.9.x/ppd/hpcups directory created when you first untarred the hplip tar.gz file to /usr/share/ppd/HP/. Then specify the path. You may have to specify the path anyway, even if the file is in /usr/share/HP/ppd. That is, hp-setup may not find it.

Specify the entire path, including the name of the ppd file. Note that when you type it in, the line doesn't wrap properly, overwriting the print of the hp-setup dialog, so you have type carefully as you won't be able to really see what you're typing. The file name will end with ppd.gz.

Hopefully, it will then say something like Description for this file, and name your printer. It will then ask do you want to use the file. Type y for yes.

It will then ask if you want to enter a location for the printer. If you want to type in a description of the printer's location, do so, otherwise just hit enter. The next question is do you want to enter any additional information or notes, again, it's up to you--enter something, or just hit the enter key.

Lastly it asks if you want to print a test page. Being frugal, (ink is expensive), I choose no, and just test it by echoing a word or two to the lp command.

If you choose to do it my way, make sure that the printer is the default printer. Note that even if it's the only printer, it has to be specified as default. This can be done with the lpadmin command, rather than going to the trouble of the GUI interfaces. If the printer is named HPC4795 then
lpadmin -d HPC4795

If the command is successful, it returns you to a command prompt. Now you can test it
echo hello |lp

At this point, it should print out hello. If not, check /var/logs/cups/error_log and see if there's a helpful message. You can also increase the log level to debug by editing the line LogLevel and changing the word info to debug and restarting cups.

Often, even if the message itself doesn't mean much to you, you can google it and see if anyone else has a useful suggestion. I've often found that it will be something simple, such as forgetting to install ghostscript.

However, if you follow these instructions, then it should work with CentOS.