问答详情
源自:3-2 基本线图绘制

代码没有问题,无法运行matplotlib相关命令

代码如下

#encoding=utf-8
import numpy as np
import matplotlib.pyplot as plt
def main():
    #line
    x=np.linspace(-np.pi,np.pi,156,endpoint=True)
    c,s=np.cos(x),np.sin(x)
    plt.figure(1)
    plt.plot(x,c)
    plt.plot(x,s)
    plt.show()

if __name__=="__main__":
    main()

报错如下

Traceback (most recent call last):

  File "D:/�����о����ĵ�/untitled/matplotlib  Python��ͼ����/test/maplotlib test2.py", line 3, in <module>

    import matplotlib.pyplot as plt

  File "D:\anaconda\lib\site-packages\matplotlib\pyplot.py", line 71, in <module>

    from matplotlib.backends import pylab_setup

  File "D:\anaconda\lib\site-packages\matplotlib\backends\__init__.py", line 16, in <module>

    line for line in traceback.format_stack()

  File "D:\anaconda\lib\site-packages\matplotlib\backends\__init__.py", line 18, in <genexpr>

    if not line.startswith('  File "<frozen importlib._bootstrap'))

UnicodeDecodeError: 'ascii' codec can't decode byte 0xd5 in position 11: ordinal not in range(128)


提问者:qq_Reborn_ewIKX5 2018-10-10 17:24

个回答

  • 珍_Lovely
    2018-10-10 20:18:54

    #encoding=utf-8
    import numpy as np
    import matplotlib.pyplot as plt
    #line
    x=np.linspace(-np.pi,np.pi,256,endpoint=True)
    c,s=np.cos(x),np.sin(x)
    plt.figure(1)
    plt.plot(x,c)
    plt.plot(x,s)
    plt.show()
    这样试一下