xxyzz / WordDumb

A calibre plugin that generates Kindle Word Wise and X-Ray files for KFX, AZW3, MOBI and EPUB eBook.
https://xxyzz.github.io/WordDumb/
GNU General Public License v3.0
386 stars 19 forks source link

Can't creat x-ray #130

Closed freezoc closed 1 year ago

freezoc commented 1 year ago

Checkboxes

Describe the bug

An error message always appears when I try to generate X-Ray.

I searched the internet and discovered that there is a common network problem in China, regardless of whether you have set up a proxy (I'm in China, and I can download documents from GitHub through a proxy).

According to some sources(a website written in Chinese), it may be caused by urllib3 versions newer than 1.26.0. They suggest that changing the file /data/spacy.json from "urllib3": { "compiled": false, "version": "1.26.10" } to "urllib3": { "compiled": false, "version": "1.25.11" } can solve the problem.

However, I'm not sure if this is a network issue, and I can't seem to locate the spacy.json file.

System Information

OS: MacOS Monterey 12.6.5 calibre : 6.17 worddumb: 3.29.1 Python version: 3.11

Error message

calibre, version 6.17.0 (darwin, embedded-python: True)
Tonnerre de Brest!: An error occurred, please copy error message then report bug at GitHub.

Starting job: Generating X-Ray for 耶鲁大学公开课:死亡 
Job: "Generating X-Ray for 耶鲁大学公开课:死亡" failed with error: 
Traceback (most recent call last):
  File "calibre/gui2/threaded_jobs.py", line 82, in start_work
  File "calibre_plugins.worddumb.parse_job", line 188, in do_job
    run_subprocess(args, input_str)
  File "calibre_plugins.worddumb.utils", line 51, in run_subprocess
    return subprocess.run(
  File "subprocess.py", line 524, in run
subprocess.CalledProcessError: Command '['/usr/local/bin/python3', '/Users/Freezoc/Library/Preferences/calibre/plugins/WordDumb.zip', '{"create_ww": false, "create_x": true, "asin": "", "book_path": "/Volumes/Others/Books/Calibre/Xie Li _Qia Gen (Shelly Kagan)/Ye Lu Da Xue Gong Kai Ke _Si Wang (156)/Ye Lu Da Xue Gong Kai Ke _Si Wang - Xie Li _Qia Gen (Shelly Kagan).epub", "acr": "", "revision": "", "model": "zh_core_web_md", "lemma_lang": "zh", "mobi_codec": "", "useragent": "WordDumb/3.29.1 (https://github.com/xxyzz/WordDumb)", "book_fmt": "EPUB", "plugin_path": "/Users/Freezoc/Library/Preferences/calibre/plugins/WordDumb.zip"}', '{"use_pos": true, "search_people": true, "model_size": "md", "zh_wiki_variant": "cn", "fandom": "", "add_locator_map": false, "preferred_formats": ["EPUB", "KFX", "AZW3", "AZW", "MOBI"], "use_all_formats": false, "minimal_x_ray_count": 2, "en_ipa": "ga_ipa", "zh_ipa": "pinyin", "choose_format_manually": true, "wiktionary_gloss_lang": "en", "kindle_gloss_lang": "en", "use_gpu": false, "cuda": "cu118", "last_opened_kindle_lemmas_language": "ca", "last_opened_wiktionary_lemmas_language": "ca", "use_wiktionary_for_kindle": false, "ca_wiktionary_difficulty_limit": 5, "da_wiktionary_difficulty_limit": 5, "de_wiktionary_difficulty_limit": 5, "el_wiktionary_difficulty_limit": 5, "en_wiktionary_difficulty_limit": 5, "es_wiktionary_difficulty_limit": 5, "fi_wiktionary_difficulty_limit": 5, "fr_wiktionary_difficulty_limit": 5, "hr_wiktionary_difficulty_limit": 5, "it_wiktionary_difficulty_limit": 5, "ja_wiktionary_difficulty_limit": 5, "ko_wiktionary_difficulty_limit": 5, "lt_wiktionary_difficulty_limit": 5, "mk_wiktionary_difficulty_limit": 5, "nl_wiktionary_difficulty_limit": 5, "no_wiktionary_difficulty_limit": 5, "pl_wiktionary_difficulty_limit": 5, "pt_wiktionary_difficulty_limit": 5, "ro_wiktionary_difficulty_limit": 5, "ru_wiktionary_difficulty_limit": 5, "sv_wiktionary_difficulty_limit": 5, "uk_wiktionary_difficulty_limit": 5, "zh_wiktionary_difficulty_limit": 5}']' returned non-zero exit status 1.

Called with args: ((156, 'EPUB', '/Volumes/Others/Books/Calibre/Xie Li _Qia Gen (Shelly Kagan)/Ye Lu Da Xue Gong Kai Ke _Si Wang (156)/Ye Lu Da Xue Gong Kai Ke _Si Wang - Xie Li _Qia Gen (Shelly Kagan).epub', <calibre.ebooks.metadata.book.base.Metadata object at 0x12e4b3b80>, 'zh'), False, True) {'notifications': <queue.Queue object at 0x12e4b1d50>, 'abort': <threading.Event object at 0x12e4b3310>, 'log': <calibre.utils.logging.GUILog object at 0x12e4b35b0>} 
Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "/Users/Freezoc/Library/Preferences/calibre/plugins/WordDumb.zip/__main__.py", line 40, in <module>
  File "/Users/Freezoc/Library/Preferences/calibre/plugins/WordDumb.zip/parse_job.py", line 312, in create_files
UnboundLocalError: cannot access local variable 'lemmas_conn' where it is not associated with a value

Reproduce steps

  1. open calibre
  2. select a book
  3. press Worddumb/creat x-ray

Screenshots or videos

No response

xxyzz commented 1 year ago

https://github.com/xxyzz/WordDumb/commit/b5239aa35dbe4385c8221d81986c01d219cbd612 fixes the variable lemmas_conn not defined error.

Most proxy errors users reported are caused by the HTTP proxy environment variables not being set correctly. Example settings:

export HTTP_PROXY='http://host:port'
export HTTPS_PROXY='http://host:port'

Please also check out calibre's manual: https://manual.calibre-ebook.com/faq.html#how-do-i-get-calibre-to-use-my-http-proxy

If you still can't figure this out, use a VPN.

freezoc commented 1 year ago

It turns out that there was a lemmas_conn error.

The problem has been solved. Thank you.