【问题标题】:ImportError: cannot import name 'TwitterPreprocessor' from 'preprocessor'ImportError:无法从“预处理器”导入名称“TwitterPreprocessor”
【发布时间】:2021-08-17 17:19:18
【问题描述】:

我正在安装该软件包以进行数据清理,

!pip install tweet-preprocessor
from preprocessor import TwitterPreprocessor

我同时使用 Jupyter 和 Colab,在 Jupyter 中使用没有问题。但是,仍然在 colab 中收到此问题:

ImportError: cannot import name 'TwitterPreprocessor' from 'preprocessor' (/usr/local/lib/python3.7/dist-packages/preprocessor/init.py)

请帮我解决这个问题。

谢谢

【问题讨论】:

  • 如果该答案对您有所帮助,您可以相应地接受并投票。显然,没有义务这样做。

标签: python pandas dataframe data-cleaning twitterapi-python


【解决方案1】:

tweet-preprocessor 根本没有您要导入的TwitterPreprocessor。看看GitHub repo - 看不到TwitterPreprocessor

建议通过:import preprocessor as p 导入(或从 GitHub 存储库导入上述名称之一)。您可以查看__init__.py 可以导入哪些名称。

ImportError: cannot import name 'TwitterPreprocessor' from 'preprocessor' ([...]\preprocessor\_init_.py)

【讨论】:

    最近更新 更多