cannot import name 'OrderedDict' from 'typing_extensions'
Hi,
In my Python 3.8 environment I'm facing this issue when I try to import KeyBERT. Here is the full stack trace:
ImportError Traceback (most recent call last)
<ipython-input-9-f28a8ea04b09> in <module>
18
19 from keyphrase_vectorizers import KeyphraseCountVectorizer, KeyphraseTfidfVectorizer
---> 20 from keybert import KeyBERT
21 from flair.embeddings import TransformerDocumentEmbeddings
22
/opt/conda/lib/python3.8/site-packages/keybert/__init__.py in <module>
----> 1 from keybert._model import KeyBERT
2
3 __version__ = "0.5.0"
/opt/conda/lib/python3.8/site-packages/keybert/_model.py in <module>
11 from keybert._mmr import mmr
12 from keybert._maxsum import max_sum_similarity
---> 13 from keybert._highlight import highlight_document
14 from keybert.backend._utils import select_backend
15
/opt/conda/lib/python3.8/site-packages/keybert/_highlight.py in <module>
1 import re
----> 2 from rich.console import Console
3 from rich.highlighter import RegexHighlighter
4 from typing import Tuple, List
5
/opt/conda/lib/python3.8/site-packages/rich/console.py in <module>
44 from . import errors, themes
45 from ._emoji_replace import _emoji_replace
---> 46 from ._log_render import FormatTimeCallable, LogRender
47 from .align import Align, AlignMethod
48 from .color import ColorSystem
/opt/conda/lib/python3.8/site-packages/rich/_log_render.py in <module>
3
4
----> 5 from .text import Text, TextType
6
7 if TYPE_CHECKING:
/opt/conda/lib/python3.8/site-packages/rich/text.py in <module>
3 from math import gcd
4 from operator import itemgetter
----> 5 from rich.emoji import EmojiVariant
6 from typing import (
7 TYPE_CHECKING,
/opt/conda/lib/python3.8/site-packages/rich/emoji.py in <module>
2 from typing import TYPE_CHECKING, Optional, Union
3
----> 4 from .jupyter import JupyterMixin
5 from .segment import Segment
6 from .style import Style
/opt/conda/lib/python3.8/site-packages/rich/jupyter.py in <module>
2
3 from . import get_console
----> 4 from .segment import Segment
5 from .terminal_theme import DEFAULT_TERMINAL_THEME
6
/opt/conda/lib/python3.8/site-packages/rich/segment.py in <module>
17 )
18
---> 19 from .cells import (
20 _is_single_cell_widths,
21 cell_len,
/opt/conda/lib/python3.8/site-packages/rich/cells.py in <module>
4
5 from ._cell_widths import CELL_WIDTHS
----> 6 from ._lru_cache import LRUCache
7
8 # Regex to match sequence of the most common character ranges
/opt/conda/lib/python3.8/site-packages/rich/_lru_cache.py in <module>
6
7 if sys.version_info < (3, 9):
----> 8 from typing_extensions import OrderedDict
9 else:
10 from collections import OrderedDict
ImportError: cannot import name 'OrderedDict' from 'typing_extensions' (/opt/conda/lib/python3.8/site-packages/typing_extensions.py)
I'm facing this issue when using with both version 0.5.0 and 0.5.1. Please suggest if there is a workaround for this issue.
Thanks
KeyBERT had been working for me about 10-ish days ago, so I explored what had changed in the last 10 days. Apart from the new version (0.5.1) of KeyBERT being released, the python library rich has been updated from 12.0 to 12.1. This is the library that is causing the issue found here - so this led to a workaround, installing an older version of rich.
Workaround:
Run pip install rich==12.0.1 in the console. KeyBERT only requires rich >= 10.4.0. This fixed aforementioned error for me.
Thank you for sharing the issue and what you did to fix it! I'll let this open for other users so that they know how to resolve the issue if they encounter it.
Thank you @chilicrabcakes, it fixed the issue.
Installing rich is not useful for me.
Installing rich is not useful for me.
Maybe i need high version of python3, now i use python3.7.0 but only version > 3.7.2 supports it.