python常见错误(持续更新)

1.matplotlib画图报错AttributeError: ‘module’ object has no attribute ‘popall’
解决方法如下:
原版本1.2.0升级成2.0.2

rpm -e python-matplotlib-1.2.0-15.el7.x86_64
pip install matplotlib==2.0.2

2.解码错误UnicodeDecodeError: ‘ascii’ codec can’t decode byte 0xe5 in position 108: ordinal not in range
解决方法:代码快里设置字符集为utf8

import sys
reload(sys)
sys.setdefaultencoding('utf8')

3.用tensorflow或者caffe做机器学习时
RuntimeError: module compiled against API version 0xa but this version of numpy is 0x9
基本上都是numpy版本的问题
解决方法

pip list|grep numpy
pip install numpy==1.3.1(视具体情况)

4.python编译碰到错误
configure: error: no acceptable C compiler found in $PATH
原因缺少编译器
安装gcc即可

yum install -y gcc*

猜你喜欢

转载自blog.csdn.net/H_haow/article/details/80498986