导入错误:无法从“预处理器”导入名称“TwitterPreprocessor”

问题描述

我正在安装数据清理包,

!pip install tweet-preprocessor
from preprocessor import TwitterPreprocessor

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

导入错误:无法从“预处理器”(/usr/local/lib/python3.7/dist-packages/preprocessor/init.py) 导入名称“TwitterPreprocessor”

请帮我解决这个问题。

谢谢

解决方法

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

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

导入错误:无法从“预处理器”导入名称“TwitterPreprocessor” ([...]\preprocessor\_init_.py)