devika icon indicating copy to clipboard operation
devika copied to clipboard

ModuleNotFoundError: No module named 'bidi.algorithm'

Open CastIronPlatypus opened this issue 2 years ago • 7 comments

I have been banging my head against the wall and just figured out that this is probably a issue with changes to the packages you're using.

ModuleNotFoundError: No module named 'bidi.algorithm'

I have tried 30-ish different times to install in different ways after going through the install instructions as-is multiple times. I get this error every time. Here's the full message:

24.07.21 21:40:51: root: INFO   : Initializing Devika...
24.07.21 21:40:51: root: INFO   : checking configurations...
24.07.21 21:40:51: root: INFO   : Initializing Prerequisites Jobs...
24.07.21 21:41:17: root: INFO   : Loading sentence-transformer BERT models...
24.07.21 21:41:20: root: INFO   : BERT model loaded successfully.
24.07.21 21:41:24: root: WARNING: Ollama not available
24.07.21 21:41:24: root: WARNING: run ollama server to use ollama models otherwise use API models
huggingface/tokenizers: The current process just got forked, after parallelism has already been used. Disabling parallelism to avoid deadlocks...
To disable this warning, you can either:
	- Avoid using `tokenizers` before the fork if possible
	- Explicitly set the environment variable TOKENIZERS_PARALLELISM=(true | false)
huggingface/tokenizers: The current process just got forked, after parallelism has already been used. Disabling parallelism to avoid deadlocks...
To disable this warning, you can either:
	- Avoid using `tokenizers` before the fork if possible
	- Explicitly set the environment variable TOKENIZERS_PARALLELISM=(true | false)
Traceback (most recent call last):
  File "/Users/jeffhaskin/Documents/Programs/devika/devika.py", line 28, in <module>
    from src.agents import Agent
  File "/Users/jeffhaskin/Documents/Programs/devika/src/agents/__init__.py", line 1, in <module>
    from .agent import Agent
  File "/Users/jeffhaskin/Documents/Programs/devika/src/agents/agent.py", line 25, in <module>
    from src.documenter.pdf import PDF
  File "/Users/jeffhaskin/Documents/Programs/devika/src/documenter/pdf.py", line 4, in <module>
    from xhtml2pdf import pisa
  File "/Users/jeffhaskin/Documents/Programs/devika/.venv/lib/python3.11/site-packages/xhtml2pdf/pisa.py", line 26, in <module>
    from xhtml2pdf.document import pisaDocument
  File "/Users/jeffhaskin/Documents/Programs/devika/.venv/lib/python3.11/site-packages/xhtml2pdf/document.py", line 25, in <module>
    from xhtml2pdf.context import pisaContext
  File "/Users/jeffhaskin/Documents/Programs/devika/.venv/lib/python3.11/site-packages/xhtml2pdf/context.py", line 39, in <module>
    from xhtml2pdf import default, parser
  File "/Users/jeffhaskin/Documents/Programs/devika/.venv/lib/python3.11/site-packages/xhtml2pdf/parser.py", line 44, in <module>
    from xhtml2pdf.tables import (  # noqa: F401
  File "/Users/jeffhaskin/Documents/Programs/devika/.venv/lib/python3.11/site-packages/xhtml2pdf/tables.py", line 21, in <module>
    from xhtml2pdf.tags import pisaTag
  File "/Users/jeffhaskin/Documents/Programs/devika/.venv/lib/python3.11/site-packages/xhtml2pdf/tags.py", line 35, in <module>
    from xhtml2pdf.charts import (
  File "/Users/jeffhaskin/Documents/Programs/devika/.venv/lib/python3.11/site-packages/xhtml2pdf/charts.py", line 7, in <module>
    from xhtml2pdf.util import getColor
  File "/Users/jeffhaskin/Documents/Programs/devika/.venv/lib/python3.11/site-packages/xhtml2pdf/util.py", line 25, in <module>
    from bidi.algorithm import get_display
ModuleNotFoundError: No module named 'bidi.algorithm'

CastIronPlatypus avatar Jul 22 '24 03:07 CastIronPlatypus

Temp solution: comment the 25th line in .venv/lib/python3.[YOURVERS]/site-packages/xhtml2pdf/util.py

#from bidi.algorithm import get_display

Seems works for me 🤔

murdercode avatar Jul 22 '24 12:07 murdercode

Hi.. change to version 0.4.2 of python-bidi

roylansaf avatar Jul 22 '24 17:07 roylansaf

I should have said; I tried that already. I did pip install python-bidi==0.4.2 and then installed requirements. After installing all requirements, I then confirmed python-bidi was still version 0.4.2. Still produced that same error when running the program.

CastIronPlatypus avatar Jul 22 '24 19:07 CastIronPlatypus

Temp solution: comment the 25th line in .venv/lib/python3.[YOURVERS]/site-packages/xhtml2pdf/util.py

#from bidi.algorithm import get_display

Seems works for me 🤔

You beautiful human. This worked for me. I'll comment again if this causes any errors, but it launches now!

CastIronPlatypus avatar Jul 22 '24 19:07 CastIronPlatypus

"algorithm.py" was removed from python-bidi in 0.5.0. The same issue just happened on my side and the problem was fixed after downgrading to 0.4.2.

This issue was also reported on python-bidi: https://github.com/MeirKriheli/python-bidi/issues/23

and it is suggested to change: from bidi.algorithm import get_display into from bidi import get_display in "site-packages/xhtml2pdf/util.py"

chunghan-lee avatar Jul 23 '24 04:07 chunghan-lee

Only a temp solution. I cannot do this to release production code. For us fixing python-bidi at 4.2 in our build fixed it. However many projects can have xhtml2pdf coming as a transitive dependency. Somebody pulling xhtml2pdf will break anyway right? xhtml2pdf needs to make this change and release perhaps?

mmn007 avatar Jul 23 '24 09:07 mmn007

Only a temp solution. I cannot do this to release production code. For us fixing python-bidi at 4.2 in our build fixed it. However many projects can have xhtml2pdf coming as a transitive dependency. Somebody pulling xhtml2pdf will break anyway right? xhtml2pdf needs to make this change and release perhaps?

what version of xhtml2pdf do you have in your build? Should I just uninstall xhtml2pdf after installing requirements? I already downgraded python-bidi, and it still gives me the same error. So one of the packages must have the updated version as a dependancies somewhere.

CastIronPlatypus avatar Jul 23 '24 18:07 CastIronPlatypus