ocropus / hocr-tools

Tools for manipulating and evaluating the hOCR format for representing multi-lingual OCR results by embedding them into HTML.
Other
371 stars 79 forks source link

ModuleNotFoundError: No module named 'bidi' #188

Closed pprw closed 1 month ago

pprw commented 1 month ago

hocr-pdf --savefile output.pdf .

returns

Traceback (most recent call last):
  File "/home/user/.local/bin/hocr-pdf", line 29, in <module>
    from bidi.algorithm import get_display
ModuleNotFoundError: No module named 'bidi'

hocr-pdf is installed from the master (with pipx install git+https://github.com/ocropus/hocr-tools.git@master --force)

It seems python-bidi 0.4.2 and earlier used bidi.algorithm and in 0.5.0 and futher use bidi only. So I tried

  1. to install python-bidi==0.4.2
$ pipx install python-bidi==0.4.2 --force
Installing to existing venv 'python-bidi'
  installed package python-bidi 0.4.2, installed using Python 3.11.2
  These apps are now globally available
    - pybidi
done! ✨ 🌟 ✨
  1. to rename in hocr-pdf file bidi.algorithm to bidi (with bidi 0.6.0 version)

In both case, I still have the `ModuleNotFoundError

stefan6419846 commented 1 month ago

You appear to not use the same virtual environment for hocr-tools and python-bidi. python-bidi is only required for hocr-pdf and thus needs to be installed manually. How this can be done should be documented somewhere for pipx which I do not use, but AFAIK uses a dedicated virtual environment for each installation while being intended for CLI applications.

For python-bidi, every version except 0.5.0 should be compatible, as only version 0.5.0 has the breaking change AFAIK and restored compatibility with 0.5.1 again.

pprw commented 1 month ago

Indeed! Thanks

$ python3 -m venv $HOME/.venvs/hocr $ source $HOME/.venvs/hocr/bin/activate $ pip install git+https://github.com/ocropus/hocr-tools.git@master --force $ pip install python-bidi