Can't use calibre

I installed calibre using community repo, but it doesn’t work no matter what I try to do with it, view a file or convert it. I can’t open epub and chm files using Okular too. I think they are related and it is related to something being wrong in the system. Here an example of error I get when I try to open a epub file with clibre. It mentions html5-parser and libxml2 library. I am new both to Linux as my OS and EOS. Can someone help me to figure out what is going on here?
Here is the error:

ebook-viewer epubtest2.epub
Traceback (most recent call last):
  File "/usr/bin/ebook-viewer", line 21, in <module>
    sys.exit(ebook_viewer())
  File "/usr/lib/calibre/calibre/gui_launch.py", line 101, in wrapper
    return func(*a, **kw)
  File "/usr/lib/calibre/calibre/gui_launch.py", line 116, in ebook_viewer
    from calibre.gui2.viewer.main import main
  File "/usr/lib/calibre/calibre/gui2/viewer/main.py", line 15, in <module>
    from calibre.gui2.viewer.ui import EbookViewer, is_float
  File "/usr/lib/calibre/calibre/gui2/viewer/ui.py", line 29, in <module>
    from calibre.gui2.viewer.annotations import (
  File "/usr/lib/calibre/calibre/gui2/viewer/annotations.py", line 11, in <module>
    from calibre.gui2.viewer.convert_book import update_book
  File "/usr/lib/calibre/calibre/gui2/viewer/convert_book.py", line 16, in <module>
    from calibre.srv.render_book import RENDER_VERSION
  File "/usr/lib/calibre/calibre/srv/render_book.py", line 25, in <module>
    from calibre.ebooks.oeb.polish.container import Container as ContainerBase
  File "/usr/lib/calibre/calibre/ebooks/oeb/polish/container.py", line 42, in <module>
    from calibre.ebooks.oeb.polish.parsing import parse as parse_html_tweak
  File "/usr/lib/calibre/calibre/ebooks/oeb/polish/parsing.py", line 10, in <module>
    import html5_parser
  File "/usr/lib/python3.10/site-packages/html5_parser/__init__.py", line 31, in <module>
    raise RuntimeError(
RuntimeError: html5-parser and lxml are using different versions of libxml2. This happens commonly when using pip installed versions of lxml. Use pip install --no-binary lxml lxml instead. libxml2 versions: html5-parser: (2, 10, 3) != lxml: (2, 9, 14)

Hmm…did you do either of things?

  1. Use sudo pip to install some python application or library?
  2. Install software without updating the system first?

If so, you should never do either of those on any Arch-based distro.

Simply updating the system with sudo pacman -Syu will fix the issue if it caused by #2 above.

If it is #1, you are going to be in something of a mess.

If it is neither of those, we will need to troubleshoot further after fully updating the system.

1 Like

I don’t think done sudo pip, I am not 100% sure but it is very unlikely. I have done sudo yay couple of times by mistake tho.

I just a pacman -Syu yesterday. Should I do it again? I have installed calibre and okular sometime ago but never tested these features in them, so I don’t know if they have been like this from start or it is something new.

Yes.

1 Like

Done, what should I do next?

Reboot and see if you get the same error.

Rebooted , giving me the same error.

What does this return?

pacman -Q | grep -e "calibre\|python-lxml\|html5"
❯ pacman -Q | grep -e "calibre\|python-lxml\|html5"
calibre 6.9.0-1
python-html5-parser 0.4.10-4
python-html5lib 1.1-11
python-lxml 4.9.1-1

What happens if you run:

sudo pacman -Syu python-html5-parser python-html5lib python-lxml

It is asking me to reinstall them, should I?

Yes, reinstall them.

Done, and it is the output:

resolving dependencies...
looking for conflicting packages...

Package (3)                    Old Version  New Version  Net Change

community/python-html5-parser  0.4.10-4     0.4.10-4       0.00 MiB
community/python-html5lib      1.1-11       1.1-11         0.00 MiB
extra/python-lxml              4.9.1-1      4.9.1-1        0.00 MiB

Total Installed Size:  5.94 MiB
Net Upgrade Size:      0.00 MiB

:: Proceed with installation? [Y/n]
(3/3) checking keys in keyring                                                                                                 [-----------------------------------------------------------------------------] 100%
(3/3) checking package integrity                                                                                               [-----------------------------------------------------------------------------] 100%
(3/3) loading package files                                                                                                    [-----------------------------------------------------------------------------] 100%
(3/3) checking for file conflicts                                                                                              [-----------------------------------------------------------------------------] 100%
:: Processing package changes...
(1/3) reinstalling python-lxml                                                                                                 [-----------------------------------------------------------------------------] 100%
(2/3) reinstalling python-html5-parser                                                                                         [-----------------------------------------------------------------------------] 100%
(3/3) reinstalling python-html5lib                                                                                             [-----------------------------------------------------------------------------] 100%
:: Running post-transaction hooks...
(1/2) Arming ConditionNeedsUpdate...
(2/2) Checking which packages need to be rebuilt

Still giving me the same error, What should I do next?

I don’t see any reference that you uninstalled calibre and okular, reboot, and then reinstall them. I’d try that. I use calibre and sigil often and they work well on EOS.

1 Like

No I didn’t reinstall them, was not sure if that has a effect on their dependencies as it looks like that it is the issue here, I will give it a try later in night as I am going to turn it off.

The runtime exception occurred because the html5-parser on your machine uses libxml2 version 2.10.3 but your python-lxml uses version 2.9.14 of libxml2. Calibre runs without any issues on my machine, so it’s likely that you messed up somewhere (a partial upgrade or the use of other package managers like pip).

The latest version of the libxml2 package on the core repo (pacman -Ss libxml2) is 2.10.3-2, the same version that your html5-parser is using. This narrows things down because you now know that it is libxml2 that’s causing the problem—there are 2 versions of libxml2 installed on your system somehow. My guess is that you installed libxml2 version 2.9.14 as a dependency of another package (perhaps a package installed via pip?).

Your best course of action right now is to uninstall calibre (sudo pacman -Rns calibre), and then reinstall it with sudo pacman -Syu calibre. If you’re lucky, pacman will take care of everything and install all the dependencies required for calibre to run. During re-installation, pacman should notify you if there are conflicting versions of libxml2 installed on your system, you can decide on a further course of action then.

2 Likes

I would primary advise to not use Calibre from the repositories but directly from https://calibre-ebook.com/download_linux installed into e.g. /opt. It as mentioned there includes all dependencies and tends to Just Work – if that’s your thing.

1 Like

Interesting, I had no idea I can install binary like this, Is it safe to use? I mean can I uninstall this kind of install like an AppImage easily. I am going to give it a try anyway, just want to know how this way of installing actually works and be prepared.

Yes, it’s safe. At install time you will be asked to create a bunch of links in /usr/bin/; other than those, a few /usr/share/applications/ .desktop files and /usr/share/icons/ icons – and as per request a nice /usr/bin/calibre-uninstall – all will be directly under /opt.

1 Like