1.问题:Python文件运行时报错
TabError: inconsistent use of tabs and spaces in indentation**
原因:说明Python文件中混有Tab和Space用作格式缩进。这通常是使用外部编辑器编辑Python文件时,自动采用Tab进行格式缩进。
解决方案:将Tab转换成4个Space
AttributeError: module 'cv2' has no attribute 'cv'**
解决方法:https://blog.csdn.net/oYeZhou/article/details/82465742
SyntaxError: (unicode error) 'utf-8' codec can't decode byte 0xc4 in positio
解决方案: 开头加上 #--coding:utf-8 --,即可
有时候加上 #--coding:GBK -- ,
cv2.error: C:\projects\opencv-python\opencv\modules\highgui\src\window.cpp:331: error: (-215) size.width>0 && size.height>0 in function cv::imshow
解决方案: 文件路径不包含中文文字
5.
IndentationError: unindent does not match any outer indentation level
解决方案:https://blog.csdn.net/u013313168/article/details/69942316
6.opencv 图像处理
**SystemError: tile cannot extend outside image**
解决方案:我这里是在图像处理时出错,因为box = (left, top, left+width, top+height),我这里的值设置有问题,设成了(100,100,100,100)
7.ubuntu18.04使用vscode报pylint is not install错误,点击install后,出现英文句子:所选择环境里没有pip
解决方案:
一:安装pip:sudo apt-get install pip,如果使用python3则需要安装pip3:sudo apt-get install python3-pip
二:使用pip安装pylint:pip install pylint或者pip3 install pylint
8.
TypeError: unsupported operand type(s) for -: 'str' and 'int'
**原因:**N-1,写成了int(N-1),识别不了
解决方案:
改成int(N)-1
一般这种情况,是由于识别不了其类型,建议全部改成str(),或者int()
9.
SyntaxError: invalid character in identifier
原因:代码行内夹杂中文的空格,tab等,非文字字符
解决方案:改成,英文状态下的字符
**10.发生异常: **
TypeError 'float' object is not callable
解决方法:
0.001(X12+X22)2)
改成:0.001(X12+X2*2)**2)
11.
IndentationError: expected an indented block
解决方法:
检查需要缩进的地方,是否符合规范
1.因为安装的Tensorflow 2不支持Tensorflow1的API而报的错,错误如下
module 'tensorflow' has no attribute 'placeholder'
解决方法:
把 import tensorflow as tf 改为
import tensorflow.compat.v1 as tf
tf.disable_v2_behavior()
补充:
AttributeError: module 'tensorflow' has no attribute 'reset_default_graph
解决方法相同
2.
Lossy conversion from float32 to uint8. Range [0, 1]. Convert image to uint8 prior to saving to suppress this warning.
解决方法:
To address this warning, in the data.py file add the following import
from skimage import img_as_ubyte
And in the saveResult functionchange io. save function to
io.imsave(os.path.join(save_path,"%d_predict.png"%i),img_as_ubyte(img))
THe function img_as_ubyte does the conversion for you and you no longer have to see the warning. In addition update your skimage to the latest version, I think 0.15
参考贴:https://github.com/zhixuhao/unet/issues/125
img_string = tf.read_file(path_image)
module 'tensorflow' has no attribute 'read_file'
解决方法
The function has been move into tensorflow.io module. You should change your code like it was done below
img_string = tf.io.read_file(path_image)