'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文件即可


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM