You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Python version: Python 3.7.5
Os: Kali linux 2020.1
When try to import Literal it Shows a error that Cannot import literal from typing ImportError: cannot import name 'Literal' from 'typing' (/usr/lib/python3.7/typing.py)
Is literal deprecated in new python version? Because Literal is present in python2 typing.py script file but not in new typing.py script file.
The Python 3.7 stdlib has an older version of typing.py and won't be updated.
The solution (which you can do for each of your Python versions) is pip3 install typing_extensions and then use from typing_extensions import Literal.
Reacted by Mikhail Liamets, Ken Schröder, Anže Pečar, Ryosuke Yabuki, Pim, Lucas O. Souza, Anjani , KENTO Yamamoto, Tyler Romero, Jakub Beránek and 8 more
Activity
gvanrossum commentedon Mar 25, 2020
The Python 3.7 stdlib has an older version of typing.py and won't be updated.
The solution (which you can do for each of your Python versions) is
pip3 install typing_extensionsand then usefrom typing_extensions import Literal.remove import Literal because it isn't used
remove Literal because it isn't used
python 3.8 required due to Literal
python 3.8 required due to Literal