使用jieba导入引用方法时,报错AttributeError: module 'jieba' has no attribute 'cut'
一、问题描述
import jieba导入后,使用jieba.cut()方法时报错AttributeError: module 'jieba' has no attribute 'cut'
二、问题分析
明明已经导包了,为什么使用包里面的方法却报错没有这个属性,原因是有可能导错包了,你要导的包有重名,导致导的这个包其实并不是正确的包
有可能是因为当前目录中有文件名与导入的包名重名了,导致文件冲突。在python中,在导入模块时,模块的搜索顺序是:
1、当前程序根目录
2、PYTHONPATH
3、标准库目录
4、第三方库目录site-packages目录
三、解决方法
经过分析后,发现我自己的目录下,也有一个同名的jieba.py文件,导致在其他文件中导入jieba这个包时,首先导入当前目录下的文件。
通过把当前目录下重名的文件修改文件名后,完美解决问题
使用jieba导入引用方法时,报错AttributeError: module 'jieba' has no attribute 'cut'的更多相关文章
- python中引入包的时候报错AttributeError: module 'sys' has no attribute 'setdefaultencoding'解决方法?
python中引入包的时候报错:import unittestimport smtplibimport timeimport osimport sysimp.reload(sys)sys.setdef ...
- [已解决]pycharm报错:AttributeError: module 'pip' has no attribute 'main'
> 更新pip后,pycharm更新模块报错,经过一番查找,现提供两种解决办法. 报错片段信息如下: AttributeError: module 'pip' has no attribute ...
- Centos6.5下安装jumpserver-1.4.1报错AttributeError: module 'gssapi' has no attribute 'GSSException'
报错: >>> import paramiko Traceback (most recent call last): File "<stdin>", ...
- unittest模块在linux报错: AttributeError: module 'unittest' has no attribute 'TestRunner'
一开始在windows下运行没有问题,但是在linux下运行却报如下错误: AttributeError: module 'unittest' has no attribute 'TestRunn ...
- 运行pytest,报错"AttributeError: 'module' object has no attribute 'xxx'"
最近学习pytest被此问题困扰,敲脑壳,实在是不该.百度解决方法一大堆,我的问题怎么也解决不了,来看一下,我是怎么解决的,各位大佬勿喷,只是自己做笔记用,谢谢. 报错信息如下: 网上解决方法是这样的 ...
- Pycharm 报错 AttributeError: module 'pip' has no attribute 'main'
1.打开文件packaging_tool.py: D:\Program files\pycharm\PyCharm 2016.3.2\helpers\packaging_tool.py 2.添加导入: ...
- python文件名不要跟模块名相同,报错AttributeError: 'module' object has no attribute 'Differ'
python中的文件都会生成pyc文件,包括模块也是这样,所以调用模块的时候,实际上会调用模块.pyc文件:在这个前提下,如果将文件名命名成跟模块名一样,在同一目录下就会生成一个跟模块名一样的pyc文 ...
- Python脚本报错AttributeError: ‘module’ object has no attribute’xxx’解决方法
最近在编写Python脚本过程中遇到一个问题比较奇怪:Python脚本完全正常没问题,但执行总报错"AttributeError: 'module' object has no attrib ...
- pycharm安装 package报错:module 'pip' has no attribute 'main'
转自: <pycharm安装 package报错:module 'pip' has no attribute 'main'> https://www.cnblogs.com/Fordest ...
随机推荐
- SqlSugarClientHelper
using SqlSugar; using System; using System.Collections.Generic; using System.Configuration; using Sy ...
- python学习手册中的一些易忘的点(前三部分)
1.ubuntu下让python脚本可直接运行: test.py文件(后缀可省)#!/usr/bin/pythonprint('wwwww') sudo chmod +x ./test.py (sud ...
- [转载]Cool, Tomcat is able to handle more than 13,000 concurrent connections
Last time I have promised you to take a look at more real life scenario regarding threads. In the la ...
- Oracle EBS APP-FND-02938 多组织例程初始化产品报错
Oralce EBS R12中引入了MOAC的控制,所有多OU的表对象都添加了数据库VPD的控制策略,需要访问这些对象中的数据,首先需要进行多组织环境的初始化,但是如果客户化的应用中也需要具备多OU的 ...
- Sharepoint 2013 多服务器域的目录服务器和搜索服务的配置
一般而言,大部分的sharepoint的管理工作均可以通过Centrlal Admin完成,可惜这个操作不得不要用powershell. 假如Webfront服务器叫 WebServer 目录服务器叫 ...
- November 20th 2016 Week 47th Sunday
Learn from yesterday, live for today, look to tomorrow. 学习昨天,活在今天,展望明天. There is always room at the ...
- npm install --save 和 --save-dev的区别
--save 会把依赖包名称添加到 package.json 文件 "dependencies" 键下--save-dev 则添加到 package.json 文件 "d ...
- python3 80行代码实现贪吃蛇
上面是实现的截图,废话不说,直接开始说一下代码 pos = { 'UP': (-1,0), 'DOWN':(+1,0), 'LEFT':(0,-1), 'RIGHT':(0,+1), } curren ...
- HTML5的新标签-整体布局
过去:<div class="header"> <div class="hgroup"> <h1>....</h1&g ...
- Python简单实现多级菜单
# -*- coding: utf-8 -*- # @Time : 2018-06-01 13:40 # @Author : 超人 # @Email : huxiaojiu111@gmail.com ...