如下当你import matplotlib.pyplot 时就会出现下面的报错
/home/zph/anaconda2/envs/tensorflow/bin/python2.7 /home/zph/桌面/Joint-Bayesian-master/src/testTensorflow.py
Traceback (most recent call last):File "/home/zph/桌面/Joint-Bayesian-master/src/testTensorflow.py", line 3, in <module>
import matplotlib.pyplot as plt
File "/home/zph/anaconda2/envs/tensorflow/lib/python2.7/site-packages/matplotlib/pyplot.py", line 72, in <module>
from matplotlib.backends import pylab_setup
File "/home/zph/anaconda2/envs/tensorflow/lib/python2.7/site-packages/matplotlib/backends/__init__.py", line 14, in <module>
line for line in traceback.format_stack()
File "/home/zph/anaconda2/envs/tensorflow/lib/python2.7/site-packages/matplotlib/backends/__init__.py", line 16, in <genexpr>
if not line.startswith(' File "<frozen importlib._bootstrap'))
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe6 in position 18: ordinal not in range(128)
Process finished with exit code 1
不是版本兼容问题
系统编码是ascii 不识别uft8
解决方案
import sys reload(sys) sys.setdefaultencoding('utf8')
放在py文件最前面