0

I have init.py that includes this code and I get the error below the code:

from __future__ import annotations

import logging

from rich.logging import RichHandler

FORMAT = "%(message)s"
logging.basicConfig(
    format=FORMAT, datefmt="[%X] ", handlers=[RichHandler()], level=logging.INFO,
)

from . import ai
from . import cli
from . import clustering
from . import games
from . import poker
from . import terminal
from . import utils

__version__ = "1.0.0rc3"

when I run it I get this error:

>>> import poker_ai
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "D:\apps\1\poker_ai\poker_ai\__init__.py", line 5, in <module>
    from rich.logging import RichHandler
ModuleNotFoundError: No module named 'rich.logging'

This is the repo if you need: https://github.com/fedden/poker_ai

Appreciate helping me to fix this error.

Amir
  • 1,667
  • 3
  • 23
  • 42
  • do you have `rich` installed? `from rich.logging import RichHandler` works for me. Try `import rich` – ted Jun 15 '21 at 10:05
  • I tried that. but it didnt make any difference. I manually also did import rich with no error but after I get this error again. – Amir Jun 15 '21 at 10:24
  • I can see logging.py under rich folder – Amir Jun 15 '21 at 10:26
  • when I trace the modules and try to run one by one from Python Idle GUI I get to a module called "colorama". I think when a module inside the module is not working the error is called on the parent file which is quite confusing. – Amir Jun 15 '21 at 10:46

2 Answers2

0

I noticed the code has an error and needs to be fixed to

from rich.rich.logging import RichHandler

instead of

from rich.logging import RichHandler

this is how the python windows installer installs the code. Nevertheless this leads to another error

ModuleNotFoundError: No module named 'colorama'

which I need to handle. Appreciate further help for 'coloroma'

Amir
  • 1,667
  • 3
  • 23
  • 42
-1

Long time since question asked but I happened upon the same and realized as well as solved most of these errors.

The majority of errors described seem to be missing packages, try installing rich, colorama etc.

  • 1
    Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Jul 26 '22 at 11:55