python opencv 无法读取文件, 在cv2.imshow() 函数报错
cv2.error: OpenCV(3.4.1) C:Miniconda3conda-bldopencv-suite_1533128839831workmoduleshighguisrcwindow.cpp:356: error: (-215) size.width>0 && size.height>0 in function cv::imshow
解决 检查路径是否有错,如果有路径有 (特别是windows) 可以考虑在括号后引用路径“”前加入r,cv2.imread(r"xxx:xxxxxxxxx.xxx") r后的字符串不转义 。或者 路径有中文。
# Name Version Build Channel
libopencv 3.4.1 h875b8b8_3 defaults
opencv 3.4.1 py37h6fd60c2_3 defaults
py-opencv 3.4.1 py37h1b0d24d_3 defaults
3.4.1 版本 还不支持中文也是 @#¥%&*( PIL skimage 等库也是可以考虑替代cv2
启动pyhon报错
(base) C:Windowssystem32>python
Python 3.7.1 (default, Dec 10 2018, 22:54:23) [MSC v.1915 64 bit (AMD64)] :: Anaconda, Inc. on win32
Type "help", "copyright", "credits" or "license" for more information.
Failed calling sys.__interactivehook__
Traceback (most recent call last):
File "C:ProgramDataAnaconda3libsite.py", line 439, in register_readline
readline.read_history_file(history)
File "C:ProgramDataAnaconda3libsite-packagespyreadline
lmain.py", line 165, in read_history_file
self.mode._history.read_history_file(filename)
File "C:ProgramDataAnaconda3libsite-packagespyreadlinelineeditorhistory.py", line 82, in read_history_file
for line in open(filename, 'r'):
UnicodeDecodeError: 'gbk' codec can't decode byte 0x93 in position 2106: illegal multibyte sequence
>>> exit()
在用户根目录,windows在C:Usersxxx 下,有个.python_history 文件,可用记事本打开 使一些历史, 删除这个文件,就没有报错了