python 脚本运行时报错: AttributeError: 'module' object has no attribute ***
最近在编写Python脚本过程中遇到一个问题比较奇怪:Python脚本完全正常没问题,但执行总报错"AttributeError: 'module' object has no attribute 'xxx'"。这其实是.pyc文件存在问题。
问题定位:
查看import库的源文件,发现源文件存在且没有错误,同时存在源文件的.pyc文件
问题解决方法:
1. 命名py脚本时,不要与python预留字,模块名等相同
2. 删除该库的.pyc文件(因为py脚本每次运行时均会生成.pyc文件;在已经生成.pyc文件的情况下,若代码不更新,运行时依旧会走pyc,所以要删除.pyc文件),重新运行代码;或者找一个可以运行代码的环境,拷贝替换当前机器的.pyc文件即可
python 脚本运行时报错: AttributeError: 'module' object has no attribute ***的更多相关文章
- Python脚本报错AttributeError: ‘module’ object has no attribute’xxx’解决方法
最近在编写Python脚本过程中遇到一个问题比较奇怪:Python脚本完全正常没问题,但执行总报错"AttributeError: 'module' object has no attrib ...
- python文件名不要跟模块名相同,报错AttributeError: 'module' object has no attribute 'Differ'
python中的文件都会生成pyc文件,包括模块也是这样,所以调用模块的时候,实际上会调用模块.pyc文件:在这个前提下,如果将文件名命名成跟模块名一样,在同一目录下就会生成一个跟模块名一样的pyc文 ...
- facenet pyhton3.5 训练 train_softmax.py 时报错AttributeError: 'dict' object has no attribute 'iteritems'
报错原因:在进行facenet进行train_softmax.py训练时,在一轮训练结束进行验证时,报错AttributeError: 'dict' object has no attribute ' ...
- zc.buildout构建项目时报错‘AttributeError: '_NamespacePath' object has no attribute 'sort'’
在使用zc.buildout构建项目时如果碰到‘AttributeError: '_NamespacePath' object has no attribute 'sort'’报错: An inter ...
- 运行pytest,报错"AttributeError: 'module' object has no attribute 'xxx'"
最近学习pytest被此问题困扰,敲脑壳,实在是不该.百度解决方法一大堆,我的问题怎么也解决不了,来看一下,我是怎么解决的,各位大佬勿喷,只是自己做笔记用,谢谢. 报错信息如下: 网上解决方法是这样的 ...
- Python脚本报错AttributeError: 'module' object has no attribute 'maketrans'
出现此错误的原因:是此文件smtp02.py 所在的目录下有string.pyc 的文件存在,与python库里的string.pyc冲突造成无法确认编译所取的类库.
- pycharm install python packaging tools时遇到AttributeError: '_NamespacePath' object has no attribute 'sort'错误
pycharm install python packaging tools时报错AttributeError: '_NamespacePath' object has no attribute 's ...
- AttributeError: 'module' object has no attribute get'
最近在写python requests相关内容易,突然报错AttributeError: 'module' object has no attribute 'get'" 脚本肯定没问题 怎么 ...
- 使用jieba导入引用方法时,报错AttributeError: module 'jieba' has no attribute 'cut'
一.问题描述 import jieba导入后,使用jieba.cut()方法时报错AttributeError: module 'jieba' has no attribute 'cut' 二.问题分 ...
随机推荐
- 剑指offer(31-35)编程题
整数中1出现的次数(从1到n整数中1出现的次数) 把数组排成最小的数 丑数 第一个只出现一次的字符位置 数组中的逆序 31.求出1~13的整数中1出现的次数,并算出100~1300的整数中1出现的次数 ...
- SpringCloud - RestTemplate 的三种使用方式
1. 直接使用 RestTemplate restTemplate = new RestTemplate(); String result = restTemplate.getForObject(&q ...
- Swift函数_外部参数名,
//1________________ /** *没使用外部参数名的函数 */ func inputScore(name:String,score1:Int,score2:Int) { } /** * ...
- Cheatsheet: 2018 03.01 ~ 2018 03.31
Docker A Developer's Guide to Docker: A Gentle Introduction The Advantages of Using Kubernetes and D ...
- java虚拟机的内存机制
我们都知道,java程序的跨平台性离不开java虚拟机,虚拟机隔绝了底层操作系统,使得java程序可以直接运行在虚拟机之上.所以,对java的学习,离不开对java虚拟机的学习与了解.下面简单整理下j ...
- 【SSH网上商城项目实战05】完成数据库的级联查询和分页
转自:https://blog.csdn.net/eson_15/article/details/51320212 上一节我们完成了EasyUI菜单的实现.这一节我们主要来写一下CategorySer ...
- MySQL常见常用的SQL优化
应尽量避免在where中使用!=或<>操作符.否则会进行全表查询 对于查询,避免全盘扫描,考虑在where或order by涉及到的列上建立索引 避免在where中进行null值判断,否则 ...
- lumen配置日志daily模式
默认的日志保存模式是single 也就是单文件模式 要想改成每日的daily模式可以在bootstrap/app.php下添加: /* * 配置日志文件为每日 */ $app->configur ...
- unity3d之简单的时钟倒计时demo
输入结束时间,开始倒计时,时间差不超过一天,附上代码:(关于个位数显示,加个判断如果小于10 显示的字符串加上0) using System.Collections; using System.Col ...
- FlatBox-WordPress Responsive Flat Design Theme
FlatBox A beautifully FlatBox with different colors. You can upload your own logo & favicon, cus ...