Python问题记录
- 【1】20190428_安装itchat失败
- 【2】20190428_OSError: cannot write mode RGBA as JPEG
- 【3】20190429_itchat每次要扫描二维码登陆
- 【4】20190429_UnicodeEncodeError: 'UCS-2' codec can't encode characters in position 1-1: Non-BMP character not supported in Tk
- 【5】20190429_图像识别Tesseract-OCR
-
- 【 5.1】tesseract is not installed or it's not in your path
- 【5.2】pytesseract.pytesseract.TesseractError: (1, 'Error opening data file \\Program Files (x86)\\Tesseract-OCR\\eng.traineddata Please make sure the TESSDATA_PREFIX environment variable is set to your "tessdata" directory. Failed loading language \'eng\' Tesseract couldn\'t load any languages! Could not initialize tesseract.')
- 【5.3】中文识别
- 【6】20190430_ValueError: image has wrong mode
- 【7】20190521_百度云自动保存文件
- 【8】20190611_存文件进Mysql
-
- 【8.1】cryptography is required for sha256_password or caching_sh
- 【8.2】pymysql.err.OperationalError: (1045, "Access denied for user 'root'@'localhost' (using password: YES)")
- 【8.3】pymysql.err.InternalError: (1049, "Unknown database 'test'")
- 【8.4】运行conn.execute(sql,t)出现pymysql.err.InternalError: (1364, "Field 'id' doesn't have a default value")
用的是Windows的python3.7.0 64的IDLE,记录学习Python过程中碰到的每个问题,持续更新~
【1】20190428_安装itchat失败
itchat用于爬微信,直接cmd中pip install itchat失败。
解决办法:
C:\Users\13183>D:
D:>cd D:\2-instsall\Python\Python37\Scripts
D:\2-instsall\Python\Python37\Scripts>pip install itchat
【2】20190428_OSError: cannot write mode RGBA as JPEG
因为RGBA的Alpha指透明度,jpg不支持,可以保存为.png文件,也可以舍弃透明度。
p=p.convert('RGB')
p.save('1.jpg')
要不是记录下来,我就忽略这第二个方法啦~
【3】20190429_itchat每次要扫描二维码登陆
要加上hotReload=True:
itchat.auto_login(hotReload=True)
【4】20190429_UnicodeEncodeError: ‘UCS-2’ codec can’t encode characters in position 1-1: Non-BMP character not supported in Tk
这个错误因为包含特殊字符(name),添加:
import sys
non_bmp_map = dict.fromkeys(range(0x10000, sys.maxunicode + 1),> 0xfffd)
name=name.translate(non_bmp_map)
【5】20190429_图像识别Tesseract-OCR
【 5.1】tesseract is not installed or it’s not in your path
PIL已安装,安装tesseract-ocr-setup-4.00.00dev.exe:
pip install pytesser3
pip install pytesseract
下载tesseract-ocr-setup-4.00.00dev.exe安装。安装