常遇问题及解决

python opencv  无法读取文件, 在cv2.imshow() 函数报错

cv2.error: OpenCV(3.4.1) C:\Miniconda3\conda-bld\opencv-suite_1533128839831\work\modules\highgui\src\window.cpp:356: error: (-215) size.width>0 && size.height>0 in function cv::imshow

解决   检查路径是否有错,如果有路径有 \ (特别是windows)  可以考虑在括号后引用路径“”前加入r,cv2.imread(r"xxx:\xxx\xxx\xxx.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:\Windows\system32>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:\ProgramData\Anaconda3\lib\site.py", line 439, in register_readline
    readline.read_history_file(history)
  File "C:\ProgramData\Anaconda3\lib\site-packages\pyreadline\rlmain.py", line 165, in read_history_file
    self.mode._history.read_history_file(filename)
  File "C:\ProgramData\Anaconda3\lib\site-packages\pyreadline\lineeditor\history.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:\Users\xxx 下,有个.python_history 文件,可用记事本打开 使一些历史, 删除这个文件,就没有报错了