Search code examples
pythonrich

ModuleNotFoundError: No module named 'rich.logging' in python


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.


Solution

  • 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'