首页 > 解决方案 > AttributeError:模块“正则表达式”没有属性“编译”

问题描述

代码:

import re
import nltk
nltk.download('stopwords')
from nltk.corpus import stopwords
from nltk.stem.porter import  PorterStemmer

我在运行以下代码时遇到的错误

AttributeError: module 'regex' has no attribute 'compile' 

我使用spyder并且包nlkt是最新的。代码在我打开spyder一次时运行,然后它停止工作。

标签: pythonnltk

解决方案


一个可能的原因是您正在隐藏re模块。你有没有命名任何脚本re.py?如果是这样,请选择其他名称。


推荐阅读