'AttributeError: ''module'' object has no attribute ''bool_''

今天在python中import caffe时遇到了错误:
File "/home/meng/.local/lib/python2.7/site-packages/skimage/util/dtype.py", line 8, in
dtype_range = {np.bool_: (False, True),
AttributeError: 'module' object has no attribute 'bool_'

AttributeError: 'module' object has no attribute 'xxx'"。这其实是.pyc文件存在问题。

问题定位:
查看/home/meng/.local/lib/python2.7/site-packages/skimage/util,存在源文件的.pyc文件

问题解决方法:

1.命名py脚本时,不要与python预留字,模块名等相同

2.删除该库的.pyc文件(因为py脚本每次运行时均会生成.pyc文件;在已经生成.pyc文件的情况下,若代码不更新,运行时依旧会走pyc,所以要删除.pyc文件),重新运行代码;或者找一个可以运行代码的环境,拷贝替换当前机器的.pyc文件即可

posted on 2017-10-24 23:14  MissSimple  阅读(4363)  评论(0编辑  收藏  举报

导航