任何人都对如何解决此问题有任何建议?我没有使用Anaconda。我拥有的Jupyter版本是1.0.0。
Traceback (most recent call last):
File "c:\python36\lib\runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "c:\python36\lib\runpy.py", line 85, in _run_code
exec(code, run_globals)
File "c:\python36\lib\site-packages\ipykernel_launcher.py", line 15, in <module>
from ipykernel import kernelapp as app
File "c:\python36\lib\site-packages\ipykernel\__init__.py", line 2, in <module>
from .connect import *
File "c:\python36\lib\site-packages\ipykernel\connect.py", line 13, in <module>
from IPython.core.profiledir import ProfileDir
File "c:\python36\lib\site-packages\IPython\__init__.py", line 56, in <module>
from .terminal.embed import embed
File "c:\python36\lib\site-packages\IPython\terminal\embed.py", line 16, in <module>
from IPython.terminal.interactiveshell import TerminalInteractiveShell
File "c:\python36\lib\site-packages\IPython\terminal\interactiveshell.py", line 19, in <module>
from prompt_toolkit.enums import DEFAULT_BUFFER, EditingMode
File "c:\python36\lib\site-packages\prompt_toolkit\__init__.py", line 16, in <module>
from .application import Application
File "c:\python36\lib\site-packages\prompt_toolkit\application\__init__.py", line 1, in <module>
from .application import Application
File "c:\python36\lib\site-packages\prompt_toolkit\application\application.py", line 38, in <module>
from prompt_toolkit.buffer import Buffer
File "c:\python36\lib\site-packages\prompt_toolkit\buffer.py", line 28, in <module>
from .application.current import get_app
File "c:\python36\lib\site-packages\prompt_toolkit\application\current.py", line 8, in <module>
from prompt_toolkit.eventloop.dummy_contextvars import ContextVar # type: ignore
File "c:\python36\lib\site-packages\prompt_toolkit\eventloop\__init__.py", line 1, in <module>
from .async_generator import generator_to_async_generator
File "c:\python36\lib\site-packages\prompt_toolkit\eventloop\async_generator.py", line 5, in <module>
from typing import AsyncGenerator, Callable, Iterable, TypeVar, Union
ImportError: cannot import name 'AsyncGenerator'
非常感谢。
答案 0 :(得分:7)
原因是prompt_toolkit的版本与Python 3.6不匹配
解决办法是降低版本
pip install --upgrade prompt-toolkit==2.0.1
答案 1 :(得分:5)
根据与同一错误文本https://github.com/python/typing/issues/530相关的Github问题,这是Python 3.6.1中修复的错误。
由于使用的是Python 3.6.0,因此应将版本升级到3.6.1或更高版本以解决此问题。
或者,设置一个工作量
if TYPE_CHECKING: from typing import AsyncGenerator