hplip需要pyqt4

我已将我的系统从19.10升级到20.04,除了无法加载hp-systray或程序的其他部分外,一切正常运行。
我遇到的问题是在20.04中找不到pyqt4。
终端错误如下:
HP Linux Imaging and Printing System (ver. 3.20.2)
System Tray Status Service ver. 2.0

Copyright (c) 2001-18 HP 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: No module named 'PyQt4'
error: Unable to load Qt4/Qt5 support. Is it installed?

我也运行了hp-check -r; 以下是输出内容:
rick@rick-M52BC-M32BC:~$ hp-check -r
Saving output in log file: /home/rick/hp-check.log

HP Linux Imaging and Printing System (ver. 3.20.2)
Dependency/Version Check Utility ver. 15.1

Copyright (c) 2001-18 HP 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: hp-check can be run in three modes:
1. Compile-time check mode (-c or --compile): Use this mode before compiling the
HPLIP supplied tarball (.tar.gz or .run) to determine if the proper dependencies
are installed to successfully compile HPLIP.                                    
2. Run-time check mode (-r or --run): Use this mode to determine if a distro    
supplied package (.deb, .rpm, etc) or an already built HPLIP supplied tarball   
has the proper dependencies installed to successfully run.                      
3. Both compile- and run-time check mode (-b or --both) (Default): This mode    
will check both of the above cases (both compile- and run-time dependencies).   

Check types:                                                                    
a. EXTERNALDEP - External Dependencies                                          
b. GENERALDEP - General Dependencies (required both at compile and run time)    
c. COMPILEDEP - Compile time Dependencies                                       
d. [All are run-time checks]                                                    
PYEXT SCANCONF QUEUES PERMISSION                                                

Status Types:
    OK
    MISSING       - Missing Dependency or Permission or Plug-in
    INCOMPAT      - Incompatible dependency-version or Plugin-version

warning: ubuntu-20.04 version is not supported. Using ubuntu-19.10 versions dependencies to verify and install...

---------------
| SYSTEM INFO |
---------------

 Kernel: 5.4.0-26-generic #30-Ubuntu SMP Mon Apr 20 16:58:30 UTC 2020 GNU/Linux
 Host: rick-M52BC-M32BC
 Proc: 5.4.0-26-generic #30-Ubuntu SMP Mon Apr 20 16:58:30 UTC 2020 GNU/Linux
 Distribution: ubuntu 20.04
 Bitness: 64 bit


-----------------------
| HPLIP CONFIGURATION |
-----------------------

HPLIP-Version: HPLIP 3.20.2
HPLIP-Home: /usr/share/hplip
warning: HPLIP-Installation: Auto installation is not supported for ubuntu distro  20.04 version 

/etc/hp/hplip.conf文件的当前内容:

# hplip.conf.  Generated from hplip.conf.in by configure.

[hplip]
version=3.20.2

[dirs]
home=/usr/share/hplip
run=/var/run
ppd=/usr/share/ppd/hplip/HP
ppdbase=/usr/share/ppd/hplip
doc=/usr/share/doc/hplip-3.20.2
html=/usr/share/doc/hplip-3.20.2
icon=/usr/share/applications
cupsbackend=/usr/lib/cups/backend
cupsfilter=/usr/lib/cups/filter
drv=/usr/share/cups/drv/hp
bin=/usr/bin
apparmor=/etc/apparmor.d
# Following values are determined at configure time and cannot be changed.
[configure]
network-build=yes
libusb01-build=no
pp-build=no
gui-build=yes
scanner-build=yes
fax-build=yes
dbus-build=yes
cups11-build=no
doc-build=yes
shadow-build=no
hpijs-install=no
foomatic-drv-install=no
foomatic-ppd-install=no
foomatic-rip-hplip-install=no
hpcups-install=yes
cups-drv-install=yes
cups-ppd-install=no
internal-tag=3.20.2
restricted-build=no
ui-toolkit=qt4
qt3=no
qt4=yes
qt5=no
policy-kit=no
lite-build=no
udev_sysfs_rules=no
hpcups-only-build=no
hpijs-only-build=no
apparmor_build=yes
class-driver=no

当前 /var/lib/hp/hplip.state 文件的内容如下:
Plugins are not installed. Could not access file: No such file or directory

当前 ~/.hplip/hplip.conf 文件的内容如下:
[upgrade]
notify_upgrade = true
last_upgraded_time = 1582830956
pending_upgrade_time = 0
latest_available_version = 3.17.10

[settings]
systray_visible = 0
systray_messages = 0

[last_used]
device_uri = hpaio:/net/officejet_5200_series?ip=192.168.1.139&queue=false
printer_name = HP_OfficeJet_5200_series
working_dir = .

[commands]
scan = /usr/bin/xsane -V %SANE_URI%

[refresh]
rate = 30
enable = false
type = 1

[polling]
enable = false
interval = 5
device_list = 

[fax]
voice_phone = 
email_address = 

[installation]
date_time = 04/27/20 18:23:19
version = 3.20.2


 <Package-name>        <Package-Desc>      <Required/Optional> <Min-Version> <Installed-Version> <Status>   <Comment>

-------------------------
| External Dependencies |
-------------------------

 error: cups          CUPS - Common Unix Printing System                           REQUIRED        1.1             -               INCOMPAT   'CUPS may not be installed or not running'
 gs                   GhostScript - PostScript and PDF language interpreter and previewer REQUIRED        7.05            9.50            OK         -
 xsane                xsane - Graphical scanner frontend for SANE                  OPTIONAL        0.9             0.999           OK         -
 scanimage            scanimage - Shell scanning program                           OPTIONAL        1.0             1.0.29          OK         -
 dbus                 DBus - Message bus system                                    REQUIRED        -               1.12.16         OK         -
 policykit            PolicyKit - Administrative policy framework                  OPTIONAL        -               0.105           OK         -
 network              network -wget                                                OPTIONAL        -               1.20.3          OK         -
 avahi-utils          avahi-utils                                                  OPTIONAL        -               0.7             OK         -

------------------------
| General Dependencies |
------------------------

 libjpeg              libjpeg - JPEG library                                       REQUIRED        -               -               OK         -
 cups-devel           CUPS devel- Common Unix Printing System development files    REQUIRED        -               -               OK         -
 cups-image           CUPS image - CUPS image development files                    REQUIRED        -               -               OK         -
 libpthread           libpthread - POSIX threads library                           REQUIRED        -               b'2.31'         OK         -
 libusb               libusb - USB library                                         REQUIRED        -               1.0             OK         -
 sane                 SANE - Scanning library                                      REQUIRED        -               -               OK         -
 sane-devel           SANE - Scanning library development files                    REQUIRED        -               -               OK         -
 libnetsnmp-devel     libnetsnmp-devel - SNMP networking library development files REQUIRED        5.0.9           5.8             OK         -
 libcrypto            libcrypto - OpenSSL cryptographic library                    REQUIRED        -               1.1.1           OK         -
 python3X             Python 2.2 or greater - Python programming language          REQUIRED        2.2             3.8.2           OK         -
 python3-notify2      Python libnotify - Python bindings for the libnotify Desktop notifications OPTIONAL        -               -               OK         -
 error: python3-pyqt4-dbus PyQt 4 DBus - DBus Support for PyQt4                         OPTIONAL        4.0             -               MISSING    'python3-pyqt4-dbus needs to be installed'
 error: python3-pyqt4 PyQt 4- Qt interface for Python (for Qt version 4.x)         REQUIRED        4.0             -               MISSING    'python3-pyqt4 needs to be installed'
 python3-dbus         Python DBus - Python bindings for DBus                       REQUIRED        0.80.0          1.2.16          OK         -
 python3-xml          Python XML libraries                                         REQUIRED        -               2.2.9           OK         -
 python3-devel        Python devel - Python development files                      REQUIRED        2.2             3.8.2           OK         -
 python3-pil          PIL - Python Imaging Library (required for commandline scanning with hp-scan) OPTIONAL        -               7.0.0           OK         -
 python3-reportlab    Reportlab - PDF library for Python                           OPTIONAL        2.0             3.5.34          OK         -

--------------
| COMPILEDEP |
--------------

 libtool              libtool - Library building support services                  REQUIRED        -               2.4.6           OK         -
 gcc                  gcc - GNU Project C and C++ Compiler                         REQUIRED        -               9.3.0           OK         -
 make                 make - GNU make utility to maintain groups of programs       REQUIRED        3.0             4.2.1           OK         -

---------------------
| Python Extentions |
---------------------

 cupsext              CUPS-Extension                                               REQUIRED        -               3.20.2          OK         -
 hpmudext             IO-Extension                                                 REQUIRED        -               3.20.2          OK         -

----------------------
| Scan Configuration |
----------------------

 hpaio                HPLIP-SANE-Backend                                           REQUIRED        -               3.20.2          OK         'hpaio found in /etc/sane.d/dll.conf'
 scanext              Scan-SANE-Extension                                          REQUIRED        -               3.20.2          OK         -

------------------------------
| DISCOVERED SCANNER DEVICES |
------------------------------

The device `hpaio:/usb/OfficeJet_5200_series?serial=TH9B5BD184` is a Hewlett-Packard OfficeJet_5200_series all-in-one


--------------------------
| DISCOVERED USB DEVICES |
--------------------------

  Device URI                      Model                   
  ------------------------------  ------------------------
  hp:/usb/OfficeJet_5200_series?  HP OfficeJet 5200 series
  serial=TH9B5BD184                                       

---------------------------------
| INSTALLED CUPS PRINTER QUEUES |
---------------------------------


HP_Fax_4
--------
Type: Fax
Device URI: hpfax:/usb/OfficeJet_5200_series?serial=TH9B5BD184
PPD: /etc/cups/ppd/HP_Fax_4.ppd
warning: Failed to read /etc/cups/ppd/HP_Fax_4.ppd ppd file
PPD Description: 
Printer status: printer HP_Fax_4 is idle.  enabled since Thu 27 Feb 2020 05:11:03 PM EST
Communication status: Good

HP_OfficeJet_5200_series
------------------------
Type: Unknown
Device URI: usb://HP/OfficeJet%205200%20series?serial=TH9B5BD184&interface=1
PPD: /etc/cups/ppd/HP_OfficeJet_5200_series.ppd
warning: Failed to read /etc/cups/ppd/HP_OfficeJet_5200_series.ppd ppd file
PPD Description: 
Printer status: printer HP_OfficeJet_5200_series is idle.  enabled since Mon 27 Apr 2020 05:22:39 PM EDT
warning: Printer is not HPLIP installed. Printers must use the hp: or hpfax: CUPS backend for HP-Devices.

HP_OfficeJet_5200_series_72D17F_3_
----------------------------------
Type: Unknown
Device URI: implicitclass://HP_OfficeJet_5200_series_72D17F_3_/
PPD: /etc/cups/ppd/HP_OfficeJet_5200_series_72D17F_3_.ppd
warning: Failed to read /etc/cups/ppd/HP_OfficeJet_5200_series_72D17F_3_.ppd ppd file
PPD Description: 
Printer status: printer HP_OfficeJet_5200_series_72D17F_3_ is idle.  enabled since Mon 27 Apr 2020 04:28:16 PM EDT
warning: Printer is not HPLIP installed. Printers must use the hp: or hpfax: CUPS backend for HP-Devices.

OfficeJet_5200_series_TH9B5BD184_
---------------------------------
Type: Unknown
Device URI: implicitclass://OfficeJet_5200_series_TH9B5BD184_/
PPD: /etc/cups/ppd/OfficeJet_5200_series_TH9B5BD184_.ppd
warning: Failed to read /etc/cups/ppd/OfficeJet_5200_series_TH9B5BD184_.ppd ppd file
PPD Description: 
Printer status: printer OfficeJet_5200_series_TH9B5BD184_ is idle.  enabled since Mon 27 Apr 2020 04:28:13 PM EDT
warning: Printer is not HPLIP installed. Printers must use the hp: or hpfax: CUPS backend for HP-Devices.


--------------
| PERMISSION |
--------------

USB             None                           Required        -        -        OK       Node:'/dev/bus/usb/001/004' Perm:'  root  lp rw- rw- rw- rw- r--'

-----------
| SUMMARY |
-----------

Missing Required Dependencies
-----------------------------
error: 'libcups2' package is missing/incompatible 
error: 'python3-pyqt4' package is missing/incompatible 
error: 'gtk2-engines-pixbuf' package is missing/incompatible 

Missing Optional Dependencies
-----------------------------
error: 'python3-dbus.mainloop.qt' package is missing/incompatible 

Total Errors: 3
Total Warnings: 3


1这个回答解决了你的问题吗?如何在我的Ubuntu上安装最新的HPLIP以支持我的HP打印机和/或扫描仪? - 使用sudo apt-get install hplip-gui命令。 - N0rbert
好的,我按照之前的帖子上的指示进行了操作,但仍然出现错误,现在缺少ui5。此外,扫描仪只能作为网络设备工作,而hp-fax似乎根本无法工作。我可以继续使用这种方式,但我更喜欢使用hp-toolbox和hp-fax,并且我希望扫描仪可以通过USB和网络同时工作。我从hp开发者网站上安装了3.20.3版本的文件,因为这个Officejet-5252在3.19.x版本中不受支持。一切都正常工作,直到升级到20.04版本,我认为之前在19.10版本上的安装有些问题。谢谢你。 - Richard W. Seitz
同时在hp-check.log中,我在第177-178行遇到了以下错误:hp-check[612282]: info: :[31;01m error: python3-pyqt4-dbus PyQt 4 DBus - PyQt4的DBus支持 可选 4.0 - 缺失 '需要安装python3-pyqt4-dbus'[0m hp-check[612282]: info: :[31;01m error: python3-pyqt4 PyQt 4- Python的Qt界面(适用于Qt版本4.x) 必需 4.0 - 缺失 '需要安装python3-pyqt4'[0m - Richard W. Seitz
根据官方HPLIP支持页面的说法,HP OfficeJet 5200从3.17.9版本开始得到支持。这意味着您可以使用Ubuntu 18.04 LTS及更高版本中的deb软件包版本。使用二进制安装程序可能会给系统带来混乱。请按照我的回答中的“卸载”部分操作,然后使用sudo apt install hplip-gui命令。 - N0rbert
好的,我已经完全删除了所有HPLIP设备的内容。我无法使用hplip-gui添加、修改或者甚至添加打印机。当我尝试使用hp-setup时,出现了以下导入错误:libhpipp.so.0。感谢任何帮助。 - Richard W. Seitz
请将完整的错误输出添加到问题正文中。以及tree /usr/share/hplip/的输出。如果输出内容较长,请使用pastebin。 - N0rbert
3个回答

你可能需要完全重新安装HP打印机支持,因为你删除了与HPLIP相关的所有内容。你可能需要访问HPLIP页面并下载、安装最新的HPLIP。如果你能够这样做,它将设置你的打印机,并给你安装正确插件的机会,以启用你打印机的所有功能。
如果在进行任何其他操作之前,你先运行了N0rbert给你的命令,可能就能避免这么多麻烦了。
sudo apt install hplip-gui

我知道,你当时不知道;我也是通过艰难的方式学到的。这个方法适用于Ubuntu系统,因为HPLIP已经安装好了,但是没有图形界面,而你需要它来获取插件。
然后运行"HPLIP Toolbox"(我是从Dash中运行的,但你也可以从命令行运行)。这将打开一个图形界面,让你有机会安装所需的插件。许多HP打印机需要安装此插件才能执行某些功能(如扫描和传真)。
每次我安装新版本的Ubuntu(或重新安装)时,我都必须这样做,因为我的HP打印机就是那种需要插件的类型,而且看起来你的打印机也是。插件不会默认加载,而且很遗憾,关于如何解决这个问题几乎没有提供任何信息。

关于二进制HPLIP的详细错误报告,请参见https://bugs.launchpad.net/hplip/+bug/1876205。 - N0rbert
首先,感谢 @NOrbert。我已经在Ubuntu 16.04上尝试过这个过程,但没有成功。我在新的笔记本电脑上安装了本周的Ubuntu 20.04,同样的命令可以正常工作! - Alex8752
这非常有帮助,而且非常合理。简而言之,错误源于没有一个图形环境来运行脚本,默认情况下脚本会调用它。谢谢。 - oemb1905

HPLIP从3.16.5及以上版本开始支持Qt5。
要启用Qt5支持,请执行以下操作:
You need to install the following dependencies
    PyQt5
    python-qt5-dbus
Go to source of hplip. By default its in ~/Downloads.
Run the following commands
    ./configure --prefix=/usr --enable-qt5 --disable-qt4
    make
    "make install" as root user

4我注意到在Ubuntu 20.04上安装HPLIP过程中,安装程序默认使用的是Python 2.7版本,这导致了一个问题。但是,一旦我将默认版本设置为3.8,我就能够成功安装HPLIP。 - Harish
2你是怎么改变它的? - nanquim
1@nanquim 我猜测是 echo $(which python) 然后使用 pyenv 来设置全局默认值。 - jmunsch

似乎在从20.04仓库安装的版本中出现了问题,因为在20.04升级之前,我在计算机上已经安装了3.20.3版本,所以我从ubuntu 20.10仓库中安装了3.20.5版本。现在除了设备管理器之外,一切似乎都正常工作。当我点击hp-systray来打开设备管理器时,它永远无法加载设备管理器。有一个gnome-shell扩展可以替代hp-systray,并且我可以从那里调用设备管理器。所以虽然不完美,但它是可以工作的。这是替代的hp应用程序的链接:https://extensions.gnome.org/extension/1339/hplip-menu/