cannot import name 'TypeGuard' from 'typing_extensions'
Asked Answered
I

2

26

I am new to Python and found the following error with swmmtoolbox package. I would really appreciate your comments. Thanks

Traceback (most recent call last):

File "C:\Users\Hydraulic Group\anaconda3\lib\site-packages\typic\compat.py", line 16, in <module>
    from typing import Final, TypedDict, Literal, Protocol, **TypeGuard**, get_origin, get_args  # type: ignore

ImportError: cannot import name 'TypeGuard' from 'typing' (C:\Users\Hydraulic Group\anaconda3\lib\typing.py)

During handling of the above exception, another exception occurred: Traceback (most recent call last):

File "E:\VARS_Research\ostrich_swmm_master\ostrich_swmm\__main__.py", line 11, in <module>
    import extract

  File "E:\VARS_Research\ostrich_swmm_master\ostrich_swmm\extract.py", line 8, in <module>
    import swmmtoolbox.swmmtoolbox as swmmtoolbox

  File "C:\Users\Hydraulic Group\anaconda3\lib\site-packages\swmmtoolbox\swmmtoolbox.py", line 19, in <module>
    from tstoolbox import tsutils

  File "C:\Users\Hydraulic Group\anaconda3\lib\site-packages\tstoolbox\tsutils.py", line 24, in <module>
    import typic

  File "C:\Users\Hydraulic Group\anaconda3\lib\site-packages\typic\__init__.py", line 4, in <module>
    from . import types, constraints

  File "C:\Users\Hydraulic Group\anaconda3\lib\site-packages\typic\types\__init__.py", line 6, in <module>
    from .dsn import *

  File "C:\Users\Hydraulic Group\anaconda3\lib\site-packages\typic\types\dsn.py", line 8, in <module>
    from typic.util import cached_property, slotted

  File "C:\Users\Hydraulic Group\anaconda3\lib\site-packages\typic\util.py", line 41, in <module>
    import typic.checks as checks

  File "C:\Users\Hydraulic Group\anaconda3\lib\site-packages\typic\checks.py", line 36, in <module>
    from typic.compat import (

  File "C:\Users\Hydraulic Group\anaconda3\lib\site-packages\typic\compat.py", line 18, in <module>
    from typing_extensions import Final, TypedDict, Literal, TypeGuard, Protocol, get_origin, get_args  # type: ignore

ImportError: cannot import name 'TypeGuard' from 'typing_extensions' (C:\Users\Hydraulic Group\anaconda3\lib\site-packages\typing_extensions.py)s about this issue.
Inlaw answered 14/9, 2021 at 9:7 Comment(1)
Update your typing_extensions.Isomer
H
62

Had the exact same problem, upgrading typing-extensions worked for me:

pip install typing-extensions --upgrade
Hurd answered 24/9, 2021 at 16:41 Comment(4)
didn't work for me, had to downgrade bokeh to 2.3.3Varicolored
It might be worth to suggest using pip via Python's -m switch to target the correct Python version. Instead of pip, use python -m pip where python is the interpreter used for running the actual code.Permit
In conda, use conda update typing_extensions. (Updated typing-extensions from 4.3.0 to 4.4.0 and worked!)Cally
My black formatter was crashing in vscode with a similar output. This fixed it - thanks!Dated
L
1

I got this error when I pip installed panel and hvplot in my conda environment. The previous replies didn't work for me, but reinstalling hvplot directly through conda worked like a charm!

conda install -c pyviz hvplot

Reference: https://hvplot.holoviz.org/index.html#installation

Laverty answered 14/4, 2022 at 15:15 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.