错误:
在安装opevncv时会出现 ImportError: No module named cv2 的错误,找不到cv2的包。
解决:
这时候安装扩展包即可:
pip install opencv-python
错误:
1 | Traceback (most recent call last): |
解决方案:sudo apt-get install -y python-qt4
问题:ValueError: Input 0 of node Reshape was passed int32 from batch_join:1 incompatible with expected int64.
解决:打开validate_on_lfw.py,找到这三个地方,data_flow_ops.FIFOQueue,labels_placeholder,control_placeholder,将他们的tf.int32全部换成tf.int64重新运行即可
错误:1
2SyntaxError:
Non-UTF-8 code starting with '\xb2' in file src/compare.py on line 58, but no encoding declared; see http://python.org/dev/peps/pep-0263/ for details
SyntaxError: Non-ASCII character ‘\xe2’ in file意思是说,在文件中存在非ASCII字符;
ASCII是8位即一个字符,一共256个字符,随着计算机的发展,现在已经用到2个或者4个字符;
解决方案:
1 | 建议在文件头追加: |
文件头追加以后
报错:
SyntaxError: (unicode error) 'utf-8' codec can't decode byte 0xb2 in position 0: invalid start byte
解决方案:
将该py文件用notepad++打开,转为utf-8编码
原因:
excel不能够有效识别出文件中的中文数据
解决方案:
1 | 加入encoding='utf-8-sig'就不会乱码了 |
1 | list_result.sort(key=lambda x:x[1]) # 根据第2个值排序 |
将元组里的字典按value值排序
输出形式为列表里的列表元组result = sorted(list_result.items(), key=lambda item: item[1])
修改为:
list_result.extend(images_distance)
...
list_result=sorted(list_result, key=lambda x:x[1])
报错:
TypeError: writerow() takes exactly one argument (2 given)
解决方案
将1
2
3
4
5with open("result.csv", "w",newline='',encoding='utf-8-sig') as csvfile:
writer = csv.writer(csvfile)
# writerows
writer.writerow([image_QUERY]+list_result[50])
改变为1
2
3
4
5with open("result.csv", "w",newline='',encoding='utf-8-sig') as csvfile:
writer = csv.writer(csvfile)
# writerows
writer.writerow([image_QUERY]+list_result[50])
错误:
python提示AttributeError: ‘NoneType’ object has no attribute ‘extend’
原因:
a=[]
b=[1,2,3,4]
a = a.extend(b)
报出a的类型变为了NoneType
extend会修改a本身,并且返回None。不能把返回值再赋值给a。
解决:
将a = a.extend(b)变为 a.extend(b)后问题解决