Skip to content

Cannot Import Literal #707

Closed
Closed

Description

@sarthak212

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.

Activity

  1. gvanrossum commented on Mar 25, 2020

    @gvanrossum
    Member

    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.

  2. added a commit that references this issue on Jan 3, 2022
  3. added a commit that references this issue on Feb 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions