ImportError: cannot import name 'TypedDict' from 'typing_extensions'

See original GitHub issue

问题描述 在pip上更新了 nonebot ( nonebot/nonebot )(pip install --upgrade nonebot),更新过程中同时将aiocqhttp更新到了版本1.4.0,Quart更新到了0.14.1,hypercorn更新到了版本0.11.2。然后试图运行nonebot,在import nonebot处报错。试图在python的互动式界面中输入import nonebotimport aiocqhttp报相同的错误。见下面贴的报错信息。

复现方法 见上。

期望的行为 正常import相关库而不报错?

日志信息

Traceback (most recent call last):
File "C:\Program Files\Python37\lib\site-packages\hypercorn\typing.py", line 9, in <module>
    from typing import Literal, Protocol, TypedDict
ImportError: cannot import name 'Literal' from 'typing' (C:\Program Files\Python37\lib\typing.py)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "bot.py", line 3, in <module>
    import nonebot
  File "C:\Program Files\Python37\lib\site-packages\nonebot\__init__.py", line 5, in <module>
    import aiocqhttp
  File "C:\Program Files\Python37\lib\site-packages\aiocqhttp\__init__.py", line 19, in <module>
    from quart import Quart, request, abort, jsonify, websocket, Response
  File "C:\Program Files\Python37\lib\site-packages\quart\__init__.py", line 6, in <module>
    from .app import Quart
  File "C:\Program Files\Python37\lib\site-packages\quart\app.py", line 32, in <module>
    from hypercorn.asyncio import serve
  File "C:\Program Files\Python37\lib\site-packages\hypercorn\asyncio\__init__.py", line 4, in <module>
    from .run import worker_serve
  File "C:\Program Files\Python37\lib\site-packages\hypercorn\asyncio\run.py", line 11, in <module>
    from .lifespan import Lifespan
  File "C:\Program Files\Python37\lib\site-packages\hypercorn\asyncio\lifespan.py", line 4, in <module>
    from ..typing import ASGIFramework, ASGIReceiveEvent, ASGISendEvent, LifespanScope
  File "C:\Program Files\Python37\lib\site-packages\hypercorn\typing.py", line 11, in <module>
    from typing_extensions import Literal, Protocol, TypedDict  # type: ignore
ImportError: cannot import name 'TypedDict' from 'typing_extensions' (C:\Program Files\Python37\lib\site-packages\typing_extensions.py)

相关代码

运行环境

  • 操作系统:Windows server 2012 R2, x64
  • OneBot(CQHTTP)实现及版本:无关
  • aiocqhttp 版本:1.4.0
  • Python 版本:3.7.3

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
cleooldcommented, May 16, 2021

Hypercorn 的問題,依賴沒有安裝全.

解決辦法 1:使用 Python 3.8

解決辦法 2: pip install typing_extensions

On Sun., May 16, 2021, 17:49 user670, @.***> wrote:

问题描述 在pip上更新了 nonebot ( nonebot/nonebot https://github.com/nonebot/nonebot )(pip install --upgrade nonebot),更新过程中同时将aiocqhttp更新到了版本1.4.0,Quart更新到了0.14.1,hypercorn更新到了版本0.11.2。然后试图运行nonebot,在import nonebot处报错。试图在python的互动式界面中输入import nonebot 或 import aiocqhttp 报相同的错误。见下面贴的报错信息。

复现方法 见上。

期望的行为 正常import相关库而不报错?

日志信息

File “C:\Program Files\Python37\lib\site-packages\hypercorn\typing.py”, line 9, in <module>

from typing import Literal, Protocol, TypedDict

ImportError: cannot import name ‘Literal’ from ‘typing’ (C:\Program Files\Python37\lib\typing.py)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):

File “bot.py”, line 3, in <module>

import nonebot

File “C:\Program Files\Python37\lib\site-packages\nonebot_init_.py”, line 5, in <module>

import aiocqhttp

File “C:\Program Files\Python37\lib\site-packages\aiocqhttp_init_.py”, line 19, in <module>

from quart import Quart, request, abort, jsonify, websocket, Response

File “C:\Program Files\Python37\lib\site-packages\quart_init_.py”, line 6, in <module>

from .app import Quart

File “C:\Program Files\Python37\lib\site-packages\quart\app.py”, line 32, in <module>

from hypercorn.asyncio import serve

File “C:\Program Files\Python37\lib\site-packages\hypercorn\asyncio_init_.py”, line 4, in <module>

from .run import worker_serve

File “C:\Program Files\Python37\lib\site-packages\hypercorn\asyncio\run.py”, line 11, in <module>

from .lifespan import Lifespan

File “C:\Program Files\Python37\lib\site-packages\hypercorn\asyncio\lifespan.py”, line 4, in <module>

from ..typing import ASGIFramework, ASGIReceiveEvent, ASGISendEvent, LifespanScope

File “C:\Program Files\Python37\lib\site-packages\hypercorn\typing.py”, line 11, in <module>

from typing_extensions import Literal, Protocol, TypedDict  # type: ignore

ImportError: cannot import name ‘TypedDict’ from ‘typing_extensions’ (C:\Program Files\Python37\lib\site-packages\typing_extensions.py)```

相关代码

运行环境

  • 操作系统:Windows server 2012 R2, x64

  • OneBot(CQHTTP)实现及版本:无关

  • aiocqhttp 版本:1.4.0

  • Python 版本:3.7.3

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/nonebot/aiocqhttp/issues/52, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADKGVBYDT4FP7M7UVTNQCPLTOA4XJANCNFSM447JLYJA .

0reactions
cleooldcommented, May 16, 2021

I have submitted this bug to hypercorn. They might update this in the future.

https://gitlab.com/pgjones/hypercorn/-/merge_requests/54

On Sun., May 16, 2021, 18:04 user670, @.***> wrote:

確保你的 typing_extensions 是最新版的 (3.10.0.0 )

谢谢,之前装的版本貌似不是最新(3.7)。问题已解决

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/nonebot/aiocqhttp/issues/52#issuecomment-841883820, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADKGVB4F7LW4VU5AC4XQKNLTOA6ODANCNFSM447JLYJA .

Read more comments on GitHub >

github_iconTop Results From Across the Web

Trying to import TypedDict from typing of tpying_extensions fails
I have code that runs on Python 3.8 and Python 3.7, but I'd rather not install typing_extensions when it isn't need.
Read more >
cannot import name 'TypeGuard' from 'typing_extensions'
I am new to Python and found the following error with swmmtoolbox package. I would really appreciate your comments. Thanks.
Read more >
Cannot import _TypedDictMeta from typing_extensions
... i get the error “ImportError: cannot import name _Typed… ... older version of typing-extensions package which is not compatible with a ...
Read more >
typing-extensions - PyPI
The typing_extensions module serves two related purposes: Enable use of new type system features on older Python versions. For example, typing.
Read more >
More types - mypy 0.991 documentation
TypedDict lets you give precise types for dictionaries that represent ... from typing import NoReturn def stop() -> NoReturn: raise Exception('no way').
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found