[SOLVED] Calibre can't find python2.backports_functools_lru_cache

This is a follow-up from another post.

Calibre is not woking after some update:

$ calibre
Traceback (most recent call last):
  File "/usr/bin/calibre", line 20, in <module>
    sys.exit(calibre())
  File "/usr/lib/calibre/calibre/gui_launch.py", line 72, in calibre
    from calibre.gui2.main import main
  File "/usr/lib/calibre/calibre/gui2/main.py", line 28, in <module>
    from calibre.utils.ipc import RC, gui_socket_address
  File "/usr/lib/calibre/calibre/utils/ipc/__init__.py", line 15, in <module>
    from polyglot.functools import lru_cache
  File "/usr/lib/calibre/polyglot/functools.py", line 11, in <module>
    from backports.functools_lru_cache import lru_cache
ImportError: No module named functools_lru_cache

In fact, the issue appears to be with python2-backports.functools_lru_cache:

$ python2 -c "from backports import functools_lru_cache"
Traceback (most recent call last):
  File "<string>", line 1, in <module>
ImportError: cannot import name functools_lru_cache

However, I don't see anything out of place:

$ python -c "import sys, pprint; pprint.pprint(sys.path)"
['',
 '/usr/lib/python37.zip',
 '/usr/lib/python3.7',
 '/usr/lib/python3.7/lib-dynload',
 '/home/manu/.local/lib/python3.7/site-packages',
 '/home/manu/src/github.com/_all/kenobi',
 '/home/manu/src/merchise/support/merchise.lint',
 '/usr/lib/python3.7/site-packages']

$ pacman -Fl python2-backports.functools_lru_cache
python2-backports.functools_lru_cache usr/
python2-backports.functools_lru_cache usr/lib/
python2-backports.functools_lru_cache usr/lib/python2.7/
python2-backports.functools_lru_cache usr/lib/python2.7/site-packages/
python2-backports.functools_lru_cache usr/lib/python2.7/site-packages/backports.functools_lru_cache-1.5-py2.7.egg-info/
python2-backports.functools_lru_cache usr/lib/python2.7/site-packages/backports.functools_lru_cache-1.5-py2.7.egg-info/PKG-INFO
python2-backports.functools_lru_cache usr/lib/python2.7/site-packages/backports.functools_lru_cache-1.5-py2.7.egg-info/SOURCES.txt
python2-backports.functools_lru_cache usr/lib/python2.7/site-packages/backports.functools_lru_cache-1.5-py2.7.egg-info/dependency_links.txt
python2-backports.functools_lru_cache usr/lib/python2.7/site-packages/backports.functools_lru_cache-1.5-py2.7.egg-info/namespace_packages.txt
python2-backports.functools_lru_cache usr/lib/python2.7/site-packages/backports.functools_lru_cache-1.5-py2.7.egg-info/requires.txt
python2-backports.functools_lru_cache usr/lib/python2.7/site-packages/backports.functools_lru_cache-1.5-py2.7.egg-info/top_level.txt
python2-backports.functools_lru_cache usr/lib/python2.7/site-packages/backports/
python2-backports.functools_lru_cache usr/lib/python2.7/site-packages/backports/functools_lru_cache.py
python2-backports.functools_lru_cache usr/lib/python2.7/site-packages/backports/functools_lru_cache.pyc
python2-backports.functools_lru_cache usr/lib/python2.7/site-packages/backports/functools_lru_cache.pyo

$ inxi -Fxz
System:    Host: pavla Kernel: 5.1.21-1-MANJARO x86_64 bits: 64 compiler: gcc v: 9.1.0 Desktop: Gnome 3.32.2 
           Distro: Manjaro Linux 
Machine:   Type: Laptop System: LENOVO product: 80UE v: Lenovo YOGA 900-13ISK2 serial: <filter> 
           Mobo: LENOVO model: VIUU4 v: SDK0J40709 WIN serial: <filter> UEFI: LENOVO v: 2UCN10T date: 10/14/2016 
Battery:   ID-1: BAT1 charge: 44.7 Wh condition: 44.8/66.0 Wh (68%) model: LGC BASE-BAT status: Unknown 
CPU:       Topology: Dual Core model: Intel Core i7-6560U bits: 64 type: MT MCP arch: Skylake rev: 3 L2 cache: 4096 KiB 
           flags: avx avx2 lm nx pae sse sse2 sse3 sse4_1 sse4_2 ssse3 vmx bogomips: 17668 
           Speed: 1574 MHz min/max: 400/3200 MHz Core speeds (MHz): 1: 1728 2: 1790 3: 1668 4: 1633 
Graphics:  Device-1: Intel Iris Graphics 540 vendor: Lenovo driver: i915 v: kernel bus ID: 00:02.0 
           Display: x11 server: X.org 1.20.5 driver: i915 resolution: <xdpyinfo missing> 
           OpenGL: renderer: Mesa DRI Intel Iris Graphics 540 (Skylake GT3e) v: 4.5 Mesa 19.1.3 direct render: Yes 
Audio:     Device-1: Intel Sunrise Point-LP HD Audio vendor: Lenovo driver: snd_hda_intel v: kernel bus ID: 00:1f.3 
           Sound Server: ALSA v: k5.1.21-1-MANJARO 
Network:   Device-1: Intel Wireless 8260 driver: iwlwifi v: kernel port: 4040 bus ID: 01:00.0 
           IF: wlp1s0 state: down mac: <filter> 
           IF-ID-1: bnep0 state: unknown speed: N/A duplex: N/A mac: <filter> 
           IF-ID-2: docker0 state: up speed: N/A duplex: N/A mac: <filter> 
           IF-ID-3: vethf193d74 state: up speed: 10000 Mbps duplex: full mac: <filter> 
Drives:    Local Storage: total: 2.05 TiB used: 1.16 TiB (56.4%) 
           ID-1: /dev/nvme0n1 vendor: Samsung model: MZVLV256HCHP-000L2 size: 238.47 GiB 
           ID-2: /dev/sdb type: USB vendor: Seagate model: Expansion size: 1.82 TiB 
Partition: ID-1: / size: 37.30 GiB used: 17.40 GiB (46.6%) fs: ext4 dev: /dev/nvme0n1p3 
           ID-2: /home size: 117.68 GiB used: 77.48 GiB (65.8%) fs: ext4 dev: /dev/nvme0n1p5 
           ID-3: swap-1 size: 1.91 GiB used: 367.1 MiB (18.8%) fs: swap dev: /dev/nvme0n1p4 
Sensors:   System Temperatures: cpu: 48.0 C mobo: 29.8 C 
           Fan Speeds (RPM): N/A 
Info:      Processes: 255 Uptime: 1d 11h 08m Memory: 7.70 GiB used: 3.30 GiB (42.9%) Init: systemd Compilers: gcc: 9.1.0 
           Shell: bash v: 5.0.7 inxi: 3.0.35 

In fact, in stable calibre raises a Traceback:

$ calibre
Traceback (most recent call last):
  File "/usr/bin/calibre", line 20, in <module>
    sys.exit(calibre())
  File "/usr/lib/calibre/calibre/gui_launch.py", line 72, in calibre
    from calibre.gui2.main import main
  File "/usr/lib/calibre/calibre/gui2/main.py", line 28, in <module>
    from calibre.utils.ipc import RC, gui_socket_address
  File "/usr/lib/calibre/calibre/utils/ipc/__init__.py", line 15, in <module>
    from polyglot.functools import lru_cache
  File "/usr/lib/calibre/polyglot/functools.py", line 11, in <module>
    from backports.functools_lru_cache import lru_cache
ImportError: No module named functools_lru_cache

Moderation note: This response made more sense on the original topic

I have just used calibre in both testing and stable without any issues.

Stable

[keith@Laptop-Stable ~]$ calibre
qt5ct: using qt5ct plugin
qt5ct: D-Bus global menu: no
qt5ct: D-Bus system tray: no
[keith@Laptop-Stable ~]$

Are you sure your on Manjaro32 (your profile indicates that your using a 64 bit machine)?
Is your system fully up to date?
What version of calibre do you have installed?
I am using the standard Manjaro32 xfce are you using a different DE (your profile indicates gnome)?
Are you running in a virtual machine?

Your error is different from the one I posted and this thread has already been marked as solved. If you are still experiencing a problem I think you should start a new thread and be sure to provide details of your system (inxi -Fxxxxz), then someone might be able to help you.

Oops. I'm on 64. Using Gnome. Not a VM; bare metal on a Lenovo Laptop. FYI, Calibre was working. I stopped working after an update (I can't really tell which or when).

Nevertheless, my system is up-to-date:

$ sudo pacman -Syu
:: Synchronizing package databases...
 core is up to date
 extra is up to date
 community                                                                         5,3 MiB   147K/s 00:37 [###############################################################] 100%
 multilib is up to date
:: Starting full system upgrade...
 there is nothing to do

Calibre is running in Python 2.7; and it depends on having backports.functools_lru_cache installed.

However, installing it shows it's installed already:

pacman -S python2-backports.functools_lru_cache
warning: python2-backports.functools_lru_cache-1.5-1 is up to date -- reinstalling

and it does not solve the issue:

$ calibre
Traceback (most recent call last):
  File "/usr/bin/calibre", line 20, in <module>
    sys.exit(calibre())
  File "/usr/lib/calibre/calibre/gui_launch.py", line 72, in calibre
    from calibre.gui2.main import main
  File "/usr/lib/calibre/calibre/gui2/main.py", line 28, in <module>
    from calibre.utils.ipc import RC, gui_socket_address
  File "/usr/lib/calibre/calibre/utils/ipc/__init__.py", line 15, in <module>
    from polyglot.functools import lru_cache
  File "/usr/lib/calibre/polyglot/functools.py", line 11, in <module>
    from backports.functools_lru_cache import lru_cache
ImportError: No module named functools_lru_cache

The problem seems to be a packaging issue in python2-backports.functools_lru_cache:

$ python2 -c "import backports.functools_lru_cache"
Traceback (most recent call last):
  File "<string>", line 1, in <module>
ImportError: No module named functools_lru_cache

Yet I can't find an explanation right now. Everything seem to be right:

$ python2 -c "import sys; print sys.path"
['', '/usr/lib/python27.zip', '/usr/lib/python2.7', '/usr/lib/python2.7/plat-linux2', '/usr/lib/python2.7/lib-tk', '/usr/lib/python2.7/lib-old', '/usr/lib/python2.7/lib-dynload', '/home/manu/.local/lib/python2.7/site-packages', '/home/manu/src/merchise/support/merchise.lint', '/usr/lib/python2.7/site-packages', '/usr/lib/python2.7/site-packages/gtk-2.0']


$ pacman -Fl python2-backports.functools_lru_cache
python2-backports.functools_lru_cache usr/
python2-backports.functools_lru_cache usr/lib/
python2-backports.functools_lru_cache usr/lib/python2.7/
python2-backports.functools_lru_cache usr/lib/python2.7/site-packages/
python2-backports.functools_lru_cache usr/lib/python2.7/site-packages/backports.functools_lru_cache-1.5-py2.7.egg-info/
python2-backports.functools_lru_cache usr/lib/python2.7/site-packages/backports.functools_lru_cache-1.5-py2.7.egg-info/PKG-INFO
python2-backports.functools_lru_cache usr/lib/python2.7/site-packages/backports.functools_lru_cache-1.5-py2.7.egg-info/SOURCES.txt
python2-backports.functools_lru_cache usr/lib/python2.7/site-packages/backports.functools_lru_cache-1.5-py2.7.egg-info/dependency_links.txt
python2-backports.functools_lru_cache usr/lib/python2.7/site-packages/backports.functools_lru_cache-1.5-py2.7.egg-info/namespace_packages.txt
python2-backports.functools_lru_cache usr/lib/python2.7/site-packages/backports.functools_lru_cache-1.5-py2.7.egg-info/requires.txt
python2-backports.functools_lru_cache usr/lib/python2.7/site-packages/backports.functools_lru_cache-1.5-py2.7.egg-info/top_level.txt
python2-backports.functools_lru_cache usr/lib/python2.7/site-packages/backports/
python2-backports.functools_lru_cache usr/lib/python2.7/site-packages/backports/functools_lru_cache.py
python2-backports.functools_lru_cache usr/lib/python2.7/site-packages/backports/functools_lru_cache.pyc
python2-backports.functools_lru_cache usr/lib/python2.7/site-packages/backports/functools_lru_cache.pyo

$ pacman -Fl python2-backports
python2-backports usr/
python2-backports usr/lib/
python2-backports usr/lib/python2.7/
python2-backports usr/lib/python2.7/site-packages/
python2-backports usr/lib/python2.7/site-packages/backports/
python2-backports usr/lib/python2.7/site-packages/backports/__init__.py
python2-backports usr/lib/python2.7/site-packages/backports/__init__.pyc

Threads merged

1 Like

calibre 3.46.0-1 is working fine for me with python2-backports.functools_lru_cache 1.5-1.

This either means you're not fully up-to-date or you have something non-standard with your setup, for example you're using a conda environment or have added extra libraries/paths to your profile.

e.g.

'/home/manu/.local/lib/python2.7/site-packages', '/home/manu/src/merchise/support/merchise.lint',

look suspicious.

Hi @jonathon,

I took a closer look. I do install PyPI packages in my local paths /home/manu/.local/lib/python2.7/site-packages with pip2 install --user.

At first I saw nothing suspicious there, but now I realize that I have backports.shutil_get_terminal_size installed in my local path, and its backports package is shadowing the one installed in the system.

So after doing pip2 install --user --force backports.functools_lru_cache Calibre works.

1 Like

Forum kindly sponsored by Bytemark