- 报错:ImportError: cannot import name imread
分析:需要install PIL or Pillow.
解决方案:pip install pillow 即可
参考链接 - UnicodeEncodeError: ‘ascii’ codec can’t encode characters in position 0-1: ordinal not in range(128)
IDE和控制台报错,原因是print时,编码和IDE自身编码不一致导致
输出时将编码转换成一致的就可以正常输出。如下。详见链接
>>> print u'中文'.encode('utf-8')
中文
db.ping(reconnect=True)
cur.execute(sql)
db.commit()
- pymysql.err.InterfaceError: (0, ‘’)
解决:添加db.ping(reconnect=True)
。
参考链接
db.ping(reconnect=True)
cur.execute(sql)
db.commit()
-
‘module’ object has no attribute ‘subplots’
import matplotlib as plt ,然后画图时,出现了这个错。
解决:改为import matplotlib.pyplotas plt
参考链接 -
使用create_engine 插入MySQL时,报错:
UnicodeEncodeError:‘latin-1’ codec can’t encode characters in position 0-1: ordinal not in range(256)
解决:
参考链接
在create_engine()中添加charset=utf8和encoding='utf-8’
engine = create_engine(mysql+mysqldb://”root:123456@127.0.0.1:3306/test?charset=utf8”,encoding=”utf-8”)