Thursday, September 8, 2011

cups - hp office jet pro 8500a

Links: open printing.org   scroll down for tarball link   uninstall hplip   hp-setup options
Hey, I like printer installations the easy way, typically in about 10 minutes or less with lpadmin and CUPS from the command line. The 8500A, however, is an HP printer. HP documentation states that HP translation software (HPLIP), in addition to CUPS, is required for all HP printers operating with Linux. Nevertheless, many HP printers work without HPLIP, once the .ppd file can be installed. I attempted to install this HP8500A without HPLIP, and it worked. The description for the process is in Part 1 below. Parts 2 and 3 document the installation of the printer using HPLIP. Some steps in Parts 2 and 3 are repeats from Part 1.

Pt 1 What worked (w/out HP software)

short version

  • Download the .ppd, even if it's inside a larger HPLIP release. Discard the remaining HPLIP software
  • Put the .ppd into /usr/share/cups/model so lpadmin can locate it
  • Add FileDevice Yes to /etc/cups/cupsd.conf if it's not already there and restart CUPS to read the change
  • Add the user to group lp (or lpadmin -- check /etc/cups/cupsd.conf to verify the group), and be sure the system can see the printer in basic user mode, eg, the printer should be visible in $ lsusb
  • Using ///dev/usb/lp0 seems to work better than usb:/dev/usb/lp0 in the installation line

long version

1. Download the latest HPLIP source tarball. Why? CUPS needs a .ppd (printer information) file for any printer it operates, HP or otherwise. However, the installation wizard is unnecessary. Only the source tarball is necessary. From the tarball, extract the relevant .ppd and discard the remaining 20MB. That is, after extracting the HP8500A ppd (hp-officejet_pro_8500_a910.ppd), discard the remaining HPLIP software.

Update 3/2013: The tarball appears to no longer be easily available. Substituted is the annoying "hplip-3.13.3.run (21.7 MB)", which most pages link to. I eventually located a tarball via this page, after scrolling down a bit.

2. During install, lpadmin searches for .ppd's in directory /usr/share/cups/model. Root up, copy the HP5800A .ppd to that directory (and chmod 644 the file) so it will be able to find it. Alternatively, in Ubuntu, these may be placed into /usr/share/ppd/cupsfilters.

3. In order to use lpadmin, activate CUPS...
# service start cups
...then fire-up udevmonitor, plug the printer in to the USB, note its /dev ID, and add the USB printer to that /dev address
# lpadmin -p hp8500 -E -v usb:/dev/usb/lp0 -m hp-officejet_pro_8500_a910.ppd
Or, if the printer is on a network, find its net address and then...
# lpadmin -p hp8500 -E -v socket://192.168.1.101/printer -m hp-officejet_pro_8500_a910.ppd

4. The above is all that is typically required. However, this printer was not detected by CUPS following installation. The HP printer apparently broadcasts in such a way that it does not allow detection without root. That is to say, if one runs $ lsusb , the HP is not found. The printer is found with # lsusb. This is a group permissions issue, so I ran $ groups and, sure enough, I was not a member of the lp group at the user level. Solution, uninstalled the printer...
# lpadmin -x HP8500A
...and added myself as a user to the lp group using the GUI invoked from
# userconfig
There's some file that can be sourced after that to update the system, but I just rebooted so save effort. I installed again and the printer was detected.

5. Attempting to print, however, the printer hung -- "processing" the file without printing it. I recalled I also had an installed USB Brother that had been working. A look at the list of the installed printers to see if there were differences revealed:
# lpstat -v
device for Brother: ///dev/usb/lp0
device for hp8500: usb://dev/usb/lp0
Note the Brother device shows a slightly different /dev URL than the HP. I uninstalled the HP again (lpadmin -x), and reinstalled using ///dev/usb/lp0. This led to an error
# lpadmin -p hp8500 -E -v ///dev/usb/lp0 -m hp8500a.ppd
lpadmin: File device URIs have been disabled! To enable, see the FileDevice directive in "/etc/cups/cupsd.conf".
Accordingly, opened the file /etc/cups/cupsd.conf
and added the line
FileDevice Yes
Restarted CUPS so the conf file would be read. Uninstalled the printer and installed it again
# lpadmin -p hp8500 -E -v ///dev/usb/lp0 -m hp8500a.ppd
Prints without problems.

Pt 2 What worked (HPLIP and other HP software)


First, proceed the first part of Part 3 below to make sure HPLIP is properly installed. This may be an extensive project requiring software updates and other bullsh*t.

Following HPLIP installation, you need to be certain the HP printer is detectable at the user level. Why? The program hp-install is necessary for installation and it must be run at the user level, not the root level. If hp-install cannot detect the printer, it cannot install it. But the HP printer broadcasts in such a way that it does not allow detection without group membership or root. That is to say, if one runs $ lsusb , the HP is not found, but it IS found with # lsusb. To correct the permission, run
# userconfig
to invoke the groups and users GUI. Add the user to the lp group and reboot. Check that the printer is detected at the user level:$ lsub If all is OK, note the USB address, which in this case was 002:003. Now you can install the printer:
$ hp-install -i --auto 002:003
Ater the installation, there is a short authentication step requiring root, but this is the final step. It should print.

Pt 3 What DIDN'T work (HPLIP and other HP software)

HPLIP v.3.11.7 goes inta...

Who knows? Some directories somewhere in my system. Did a standard configure, which dumped-out and told me I couldn't do a network build without SNMP installed. Annoying and unnecessarily prohibitive, since all an Ethernet printer needs is a TCP/IP stack, which was already there, and I wasn't going to rearrange my SNMP installation just for HPLIP requirements. But what could I do -- the HPLIP programmers had hard-coded the SNMP requirement? Ok then, decision made: forget networking. So, disabled network capability, then completed a standard make and # make-install. Again, no telling into which directories.

will HPLIP work?

Come on, you know it didn't. The first error looked like this
Filter "hpcups" for printer "HP8500A" not available: No such file or directory
A guy, ccin1492, on Linux Questions found that his similar problem was related to where HPLIP was putting its files:
It appears that HPLIP is putting stuff in one directory /usr/lib64/cups/filter, but CUPS is putting stuff in /usr/lib/cups/filter. So to fix my problem I linked the following files into /usr/lib/cups/filter so CUPS can see them.

hpcups*
hplipjs*
pstoraster*
pstopxl*
And so on. In my installation, it appeared that the HPLIP was putting stuff in to /usr/lib/cups/filter, but that's not where CUPS was looking. CUPS was looking for shiat where it usually does, in /usr/share/cups/model. So I made soft links to that directory but I still had no luck. Next thing, I ran hp-check. Here are the errors it located (leaving out the successes)
$ hp-check -t
Checking for dependency: CUPS DDK - CUPS driver development kit...
warning: NOT FOUND! This is an OPTIONAL/RUNTIME ONLY dependency. Some HPLIP functionality may not function properly.

Checking for dependency: libnetsnmp-devel - SNMP networking library development files...
error: NOT FOUND! This is a REQUIRED dependency. Please make sure that this dependency is installed before installing or running HPLIP.

Checking for dependency: PIL - Python Imaging Library (required for commandline scanning with hp-scan)...
warning: NOT FOUND! This is an OPTIONAL/RUNTIME ONLY dependency. Some HPLIP functionality may not function properly.

Checking for dependency: PolicyKit - Administrative policy framework...
warning: NOT FOUND! This is an OPTIONAL/RUNTIME ONLY dependency. Some HPLIP functionality may not function properly.

Checking for dependency: PyQt 4 DBus - DBus Support for PyQt4...
error: NOT FOUND! This is a REQUIRED/RUNTIME ONLY dependency. Please make sure that this dependency is installed before installing or running HPLIP.

Checking for dependency: Reportlab - PDF library for Python...
warning: NOT FOUND! This is an OPTIONAL/RUNTIME ONLY dependency. Some HPLIP functionality may not function properly.
How wonderful to have HPLIP working for me, right?

removing HPLIP

Let's get this garbage out and try something else. To remove HPLIP, I first had to figure out where it was. Looking around (another half hour), the two main places appeared to be /usr/local/bin and /usr/local/share/hplip. Accordingly, I destroyed them.
# rm -r /usr/local/bin/hp*
# rm -r /usr/local/share/hplip
# rm -r /usr/local/share/cups/drv/*
I left hpcups, in case I needed that for the ppd I intended to retrieve from open printing.org. I knew some of the HP ppd's at OpenPrinting were standalone instead of HPLIP dependent. Digging into the OpenPrinting HP8500A documentation though, I was still eventually routed back to HPLIP. But I didn't give up. I figured that, if I could just edit an HP ppd enough to make it work with cupsd instead of requiring hpcups, I'd be set. And I would have been set, but no, inside the HP8500A ppd, it makes proprietary HP printer calls which CUPS does not independently recognize. Dang it, back to needing HPLIP or just getting a Brother printer (they all work like a charm with CUPS).

hplip again

By this point, I had wasted more than 12 man hours configuring the "free" HP8500A I had access to, when I could have instead bought a network compatible Brother HL-2270DW for $100. Really smart. Anyway, the first step to returning HPLIP was deleting my manual installation of the ppd
# lpadmin -x HP8500A
Next, recompiling. This time, I didn't bother with fax, scanner, copier, or network capability, hopefully to make it a simple HPLIP install for basic USB printing.
$ configure --disable-network-build --disable-hpijs-only-build --disable-qt4 --enable-qt3 --disable-fax-build
After installation, received errors
$ hp-setup
Traceback (most recent call last):
File "/usr/local/bin/hp-setup", line 45, in
from base import device, utils, tui, models, module
File "/usr/local/share/hplip/base/device.py", line 39, in
import status
File "/usr/local/share/hplip/base/status.py", line 45, in
import hpmudext
ImportError: No module named hpmudext
Look for hpmudext.
$ find -name hpmudext*
./usr/local/lib/python2.6/site-packages/hpmudext.so
./usr/local/lib/python2.6/site-packages/hpmudext.la
It's in there, so for some reason HPLIP can't find the directory or doesn't recognize the version. Check python version.
$ python -V
Python 2.6.1
Noting here, that Python 2.6.1 goes with HPLIP version 3.5.10-4 , but I have HPLIP version 3.11.7 compiled and installed. It might be advisable to remove the newer version of HPLIP I have installed and replace it by compiling and installing the older 3.5.10-4 version of HPLIP, but the printer (HP8500A) is a new model and there is no ppd support in the older 3.5 HPLIP. I'll need that newer HPLIP to interface with the printer. What to do? I could save the newer ppd and attempt to use it with the older HPLIP, I suppose. First lets make a soft link to where HPLIP is finding other modules and see if it can locate hpmudext.so there.
# ln -s /usr/local/lib/python2.6/site-packages/hpmudext.so /usr/lib/python2.6/hpmudext.so
# ln -s /usr/local/lib/python2.6/site-packages/hpmudext.la /usr/lib/python2.6/hpmudext.la
Better, but still errors.
$ hp-setup
warning: CUPSEXT could not be loaded. Please check HPLIP installation.
Look for cupsext.
$ find -name cupsext*
./usr/local/lib/python2.6/site-packages/cupsext.so
./usr/local/lib/python2.6/site-packages/cupsext.la
Appears same problem there as with hpmudext, so lets make softlinks for cupsext too.
# ln -s /usr/local/lib/python2.6/site-packages/cupsext.so /usr/lib/python2.6/cupsext.so
# ln -s /usr/local/lib/python2.6/site-packages/cupsext.la /usr/lib/python2.6/cupsext.la
Also made similar links to scanext and pcardext, to complete the four Python extension links. Now let's try to run hp-setup again.
$ hp-setup

HP Linux Imaging and Printing System (ver. 3.11.7)
Printer/Fax Setup Utility ver. 9.0

Copyright (c) 2001-9 Hewlett-Packard Development Company, LP
This software comes with ABSOLUTELY NO WARRANTY.
This is free software, and you are welcome to distribute it
under certain conditions. See COPYING file for more details.

error: PyQt not installed. GUI not available. Exiting.
warning: Qt/PyQt 3 initialization failed.
error: hp-setup requires GUI support (try running with --qt4). Also, try using interactive (-i) mode.
Appears we have functionality using the softlink hack, but no GUI. We can live without a GUI: not into engineering a PyQt install. So let's attempt "interactive mode" for another half page printout of information.
$ hp-setup -i

HP Linux Imaging and Printing System (ver. 3.11.7)
Printer/Fax Setup Utility ver. 9.0

Copyright (c) 2001-9 Hewlett-Packard Development Company, LP
This software comes with ABSOLUTELY NO WARRANTY.
This is free software, and you are welcome to distribute it
under certain conditions. See COPYING file for more details.

(Note: Defaults for each question are maked with a '*'. Press to accept the default.)


Using connection type: usb

error: No device selected/specified or that supports this functionality.
Have to read up on hp-setup command options apparently. Here's a good page for hp-setup commands that I'll also put above in the links. Meanwhile, let's go purchase a USB cable - getting close.

permissions

Along with its other problems, HPLIP brings a permission complication. The HP printer broadcasts in such a way that it does not allow detection without root. That is to say, if one runs $ lsusb , the HP is not found. The printer is found with # lsusb. But this means hp-install, which is run at the user level, cannot locate the printer and install it until this permission is addressed. I ran $ groups and noted I was not a member of the lp group.
# userconfig
Added the user to the lp group -- there's some file you can source after that to update it, but it's easier just to reboot. Following the reboot, the user level $ lsub found the printer at 002:003. At that point, I simply ran
$ hp-install -i --auto 002:003
This successfully added the printer, the only pause being to authenticate as root during the final step. I have a Brother also installed (CUPS only) and this is how the print options appeared when I selected "Print" in a document menu.

On the CUPS side, cupsd also apparently allowed HPLIP to write into the configuration file /etc/cups/printers.conf. The working configuration file (including the Brother):
# cat /etc/cups/printers.conf
Printer configuration file for CUPS v1.3.9
# Written by cupsd on 2011-09-10 15:16
<Printer Brother>
Info Brother
DeviceURI file:///dev/usb/lp0
State Idle
StateTime 1303970446
Accepting Yes
Shared Yes
JobSheets none none
QuotaPeriod 0
PageLimit 0
KLimit 0
OpPolicy default
ErrorPolicy stop-printer
</Printer>
<Printer Officejet_Pro_8500_A910>
Info Automatically setup by HPLIP
Location
DeviceURI hp:/usb/Officejet_Pro_8500_A910?serial=3VN0DGP2XN
State Idle
StateTime 1315693016
Accepting Yes
Shared Yes
JobSheets none none
QuotaPeriod 0
PageLimit 0
KLimit 0
OpPolicy default
ErrorPolicy stop-printer
</Printer>

No comments: