python jieba 结巴分词报错 AttributeError: 'module' object has no attribute 'cut'
2017-06-29 20:50
726 查看
首先这个AttributeError: ‘module’ object has no attribute ‘cut’ 报错的原因是因为有jieba.py这个文件存在,或者jieba这样命名的文件存在,很多新人使用结巴 来分词的时候命名直接为jieba.py,但是其实官方给的教程代码里有import jieba,这样就会引用到你自己这个教程文件jieba.py,而没有引用官方的库,这样自然cut这个方法就没有,所以报错。
解决方法:
1、不要使用jieba.py来命名你的测试文件。
2、你一开始就是用jieba.py来命名,出现错误之后,会产生一个jieba.pyc文件,如果你现在改了文件名,将jieba.py改为jieba_Test.py,这个时候运行还出错,那么原因就是因为jieba.pyc这个文件你没有删除,你需要删除这个jieba.pyc文件,然后你继续运行,就不会出错了。
官方jieba分词Github网址有很多用处,里面有很多其他人碰到的困难,附上大家都需要的链接,希望对大家有用:https://github.com/fxsjy/jieba/issues
解决方法:
1、不要使用jieba.py来命名你的测试文件。
2、你一开始就是用jieba.py来命名,出现错误之后,会产生一个jieba.pyc文件,如果你现在改了文件名,将jieba.py改为jieba_Test.py,这个时候运行还出错,那么原因就是因为jieba.pyc这个文件你没有删除,你需要删除这个jieba.pyc文件,然后你继续运行,就不会出错了。
官方jieba分词Github网址有很多用处,里面有很多其他人碰到的困难,附上大家都需要的链接,希望对大家有用:https://github.com/fxsjy/jieba/issues
相关文章推荐
- python 中出现的AttributeError: 'module' object has no attribute '_handlerList'
- python3 报错: AttributeError: 'module' object has no attribute 'urlopen'
- Python AttributeError: ‘module’ object has no attribute ‘A’
- Python脚本报错AttributeError: ‘module’ object has no attribute’xxx’解决方法
- [python错误]builtins.AttributeError: 'module' object has no attribute 'request'
- python错误:AttributeError: 'module' object has no attribute 'setdefaultencoding'问题的解决方法
- python opencv:AttributeError: 'module' object has no attribute 'cv' FOURCC
- python运行不了 AttributeError: module object has no attribute getdefaultlocale
- python大坑:AttributeError: 'module' object has no attribute 'Workbook'
- Python脚本报错AttributeError: ‘module’ object has no attribute’xxx’解决方法
- Python脚本报错AttributeError: ‘module’ object has no attribute’xxx’解决方法
- python运行不了 AttributeError: module object has no attribute getdefaultlocale
- python 错误解析 AttributeError: 'module' object has no attribute 'dumps'
- AttributeError: module object has no attribute “Series”. Code works in Python
- Python3.X识别混合编码,顺便解决“AttributeError: 'module' object has no attribute 'urlopen'”
- Python脚本报错AttributeError: ‘module’ object has no attribute’xxx’解决方法
- Python脚本报错AttributeError: ‘module’ object has no attribute’xxx’
- 【python学习笔记(2)】脚本报错"AttributeError: 'module' object has no attribute 'xxx'"解决方法
- 解决Python报错: AttributeError: 'module' object has no attribute '_base'
- Python 【精】AttributeError: 'Module' object has no attribute 'STARTF_USESHOWINDOW'