tensorflow 在anaconda 环境下import matplotlib.pyplot失败

如下当你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
    import matplotlib.pyplot as plt
  File "/home/zph/anaconda2/envs/tensorflow/lib/python2.7/site-packages/matplotlib/pyplot.py", line 72, in
    from matplotlib.backends import pylab_setup
  File "/home/zph/anaconda2/envs/tensorflow/lib/python2.7/site-packages/matplotlib/backends/__init__.py", line 14, in
    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
    if not line.startswith('  File " 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文件最前面


你可能感兴趣的:(question,set,学习笔记)