【问题标题】:'ModuleNotFoundError: No module named nltk.metrics' on 'import nltk''ModuleNotFoundError: No module named nltk.metrics' on 'import nltk'
【发布时间】:2021-09-10 18:00:55
【问题描述】:

我在 Ubuntu 上工作,并通过 apt-get 为 Python 3.6 安装了 NLTK。 这是我的问题:


>>> import nltk
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/wizard/.local/lib/python3.6/site-packages/nltk/__init__.py", line 128, in <module>
    from nltk.collocations import *
  File "/wizard/.local/lib/python3.6/site-packages/nltk/collocations.py", line 39, in <module>
    from nltk.metrics import (
ModuleNotFoundError: No module named 'nltk.metrics'

我是 Ubuntu 的初学者,所以我不知道如何解决这个问题。我假设度量模块没有与其他模块一起安装?

【问题讨论】:

    标签: python python-3.x ubuntu nltk modulenotfounderror


    【解决方案1】:

    不应使用apt-get 安装Python 库,而应使用pip

    在您的情况下,您应该使用pip install ntlk 安装它。 如果您是 Python 新手并且不了解包管理模块 Pip,请查看this website

    我建议您在使用 Python 时也使用虚拟环境,请查看信息here

    【讨论】:

    • 我在服务器上工作,并被建议使用 apt-get,而不是像以前那样使用 pip 在本地安装(结果相同)
    • 抱歉,那时我不知道答案。我看不出pip install nltk 产生任何错误的原因。我只能猜测您有环境或路径问题,并且没有安装/或查看正确的位置。
    猜你喜欢
    • 2023-04-03
    • 1970-01-01
    • 2020-04-17
    • 1970-01-01
    • 1970-01-01
    • 2023-01-16
    • 1970-01-01
    • 1970-01-01
    • 2021-11-22
    相关资源
    最近更新 更多