Solved Update broke calibre's ebook-covert (on some files)

Most definitely a first world problem as it's something I use infrequently, and can work around by starting a bhyve Linux machine, and doing the conversion there. At any rate, at some point, (I am not sure when), calibre's ebook convert, especially when I try to convert a text file to an epub, will fail with

Code:
 ebook-convert gpgnotes.txt gpgnotes.epub
1% Converting input to HTML...
InputFormatPlugin: TXT Input running
on /home/scottro/textfiles/gpgnotes.txt
Traceback (most recent call last):
  File "/usr/local/bin/ebook-convert", line 21, in <module>
    sys.exit(main())
  File "/usr/local/lib/calibre/calibre/ebooks/conversion/cli.py", line 422, in main
    plumber.run()
  File "/usr/local/lib/calibre/calibre/ebooks/conversion/plumber.py", line 1122, in run
    self.oeb = self.input_plugin(stream, self.opts,
  File "/usr/local/lib/calibre/calibre/customize/conversion.py", line 245, in __call__
    ret = self.convert(stream, options, file_ext,
  File "/usr/local/lib/calibre/calibre/ebooks/conversion/plugins/txt_input.py", line 209, in convert
    det_encoding = detect(txt[:4096])
  File "/usr/local/lib/calibre/calibre/ebooks/chardet.py", line 112, in detect
    from calibre_extensions.uchardet import detect as implementation
ImportError: /usr/local/lib/calibre/calibre/plugins/uchardet.so: Undefined symbol "PyModule_AddObjectRef"
I though it might be from mixing ports and packages so tried removing calibre, running pkg autoremove and reinstalling from ports, but the issue remains. (for packages, I use latest, not quarterly). As web searching has shown me nothing, I suspect it's a Just Me(tm) issue, but thought I'd ask here and see if anyone had ideas.

ebook-convert works on most pdfs to epub--I think I've had a similar error happen on one pdf, but am not sure, when I tried a few before posting this thread, they all worked.
 
Last edited by a moderator:
No,
Code:
 pkg check -ad
gave no errors. I tried reinstalling uchardet using the port, but no joy. Thank you for the suggestions thogh.
 
PyModule_AddObjectRef was added from Python 3.10.

Recently, exp-run for upgrading default python from 3.9 to 3.11 were running. It seems that the transition took place. You should pkg upgrade, so that python 3.11 and its libraries are installed.
 
Running package update, then package upgrade, shows nothing needs to be upgraded. Doing package search for python only shows 3.9 packages available. There's a few important things I have, that depend upon python, so as the only thing I use calibre for is the ebook-convert, which works on pdfs, which I do most frequently, for now, I'll leave it alone. Thank you for the information, though.


EDIT. I was mistaken, and found the python311 package.
 
I should add, that the Linux bhyve install I've been using has python-3.12, so again, I thank you. But I'm not sure what the results would be of changing /usr/ports/Mk/bsd.default--versions.mk to default to python-3.11 and it's more important that some other stuff keeps working.
 
Yes it looks as if, from that link, that it might cause problems with other things. So, for now, I'll just my bhyve Linux install if I need ebook-convert, which I probably use just once or twice a year. That's the only part of calibre I use, actually.
 
In the end, I didn't have to do anything. Calibre's various dependencies were updated to use py311 packages and now ebook-convert is working. I want to thank everyone who offered suggestions and the various people who gave the actual cause of the issue and solutions.
 
I did a pkg upgrade but now in trying to follow the procedure in /usr/ports/UPDATING to upgrade py39- packages I get errors like

# for i in $(pkg query -g %n 'py39-*'); do pkg set -yn ${i}:py311-${i#py39-}; done
pkg: sqlite error while executing UPDATE packages SET name='py311-anyio' WHERE id=15274 in file pkgdb.c:2504: UNIQUE constraint failed: packages.name
pkg: Package database is busy while closing!
 
I also tried that. a few days ago, and had issues. That was on an unimportant machine where I was checking if it would break anything, and it gave me an issue on another program I use. So, this time, I didn't do anything. Using pkg just wound up installing all
the needed py311 stuff--that is, I just did pkg update, pkg upgrade, (not specifying anything) and pkg removed some old py39 stuff, and installed some py311 stuff. It gave me one small issue because it removed a py39 package that I use with weechat to use it with slack, py39-websocket-client, and then I couldn't use weechat with slack until I installed py311-websocket-client, but pkg replaced all the other py39 stuff without me doing anything.

14.1-RELEASE is already out, too, so I would just wait, especially if using package. It might do most of it for you automagically.
 
I am running stable/14 so I will have to figure this out somehow!

I have a VM running release versions that I freebsd-updated to 14.1-RELEASE with very few packages that is still running python39. No such automagic luck!
 
Best of luck with it. It might be because even my main workstation is fairly sparse. I don't know if it's any use to you but I see it deinstalled about 60 py39 packages, though I haven't checked how many were automatically replaced with 3.11
 
I suspect this has to do with 3 digit version number. I did pkg set -yn py39-anyio:py38-anyio and then pkg set -yn py38-anyio:py39-anyio to revert it. Both of these succeeded but pkg set -yn py39-anyio:py311-anyio failed.
 
I understand now what is happening. The "pkg set" fails because "py311-anyio" was already installed by the previous upgrade & the above renaming would create duplicate entries but the name field must be unique. The fix was to simply remove all "py39-*" ports. Later "pkg check -d -a" was clean.
 
Back
Top