无法导入pyLDAvis-ModuleNotFoundError:没有名为“ _contextvars”的模块

时间:2019-05-24 09:21:52

标签: python machine-learning nlp

我正在尝试导入pyLDAvis,但它给出了错误ModuleNotFoundError:尽管我同时安装了pyLDAvis和contextvars,但没有名为“ _contextvars”的模块。错误如下

Traceback (most recent call last):
  File "C:/Users/ebru/Documents/Arda Docs/Mydocs/ITLS/Research/Tüpraş/Python Codes/Tupras_NLPv04.py", line 249, in <module>
    import pyLDAvis
  File "C:\Users\ebru\PycharmProjects\Tuprasv01\venv\lib\site-packages\pyLDAvis\__init__.py", line 44, in <module>
    from ._display import *
  File "C:\Users\ebru\PycharmProjects\Tuprasv01\venv\lib\site-packages\pyLDAvis\_display.py", line 7, in <module>
    import jinja2
  File "C:\Users\ebru\PycharmProjects\Tuprasv01\venv\lib\site-packages\jinja2\__init__.py", line 82, in <module>
    _patch_async()
  File "C:\Users\ebru\PycharmProjects\Tuprasv01\venv\lib\site-packages\jinja2\__init__.py", line 78, in _patch_async
    from jinja2.asyncsupport import patch_all
  File "C:\Users\ebru\PycharmProjects\Tuprasv01\venv\lib\site-packages\jinja2\asyncsupport.py", line 13, in <module>
    import asyncio
  File "C:\Users\ebru\AppData\Local\Programs\Python\Python37-32\lib\asyncio\__init__.py", line 8, in <module>
    from .base_events import *
  File "C:\Users\ebru\AppData\Local\Programs\Python\Python37-32\lib\asyncio\base_events.py", line 39, in <module>
    from . import events
  File "C:\Users\ebru\AppData\Local\Programs\Python\Python37-32\lib\asyncio\events.py", line 14, in <module>
    import contextvars
  File "C:\Users\ebru\AppData\Local\Programs\Python\Python37-32\lib\contextvars.py", line 1, in <module>
    from _contextvars import Context, ContextVar, Token, copy_context
ModuleNotFoundError: No module named '_contextvars'

我试图删除contextvars.py中的下划线,但没有用。

绘图工具

import pyLDAvis
import pyLDAvis.sklearn

1 个答案:

答案 0 :(得分:0)

根据https://github.com/axnsan12/drf-yasg/issues/362#issuecomment-494360308,此问题可能是由于virtualenv未升级到已安装的Python版本所致。

此外,3.7.4已发布并包含与上下文变量有关的更改。也许升级到那个有帮助吗?