This call to matplotlib.use() has no effect because the backend has already been chosen; matplotlib.

question: 今天运行paddle中样例线性回归中的波尔顿房价预测分析代码,出现了下列问题:

E:\ProgramData\Anaconda3\python.exe F:/PythonWork/paddle/linearRegression/housing.py

E:\ProgramData\Anaconda3\lib\site-packages\paddle\dataset\uci_housing.py:49: UserWarning: 
This call to matplotlib.use() has no effect because the backend has already
been chosen; matplotlib.use() must be called *before* pylab, matplotlib.pyplot,
or matplotlib.backends is imported for the first time.

The backend was *originally* set to 'TkAgg' by the following code:
  File "F:/PythonWork/paddle/linearRegression/housing.py", line 125, in <module>
    main()
  File "F:/PythonWork/paddle/linearRegression/housing.py", line 87, in main
    plot_prompt = Ploter(train_prompt, test_prompt)
  File "E:\ProgramData\Anaconda3\lib\site-packages\paddle\utils\plot.py", line 54, in __init__
    import matplotlib.pyplot as plt
  File "E:\ProgramData\Anaconda3\lib\site-packages\matplotlib\pyplot.py", line 71, in <module>
    from matplotlib.backends import pylab_setup
  File "E:\ProgramData\Anaconda3\lib\site-packages\matplotlib\backends\__init__.py", line 16, in <module>
    line for line in traceback.format_stack()


  matplotlib.use('Agg')

Figure(640x480)
train cost, Step 0, Cost 619.419312

解决方式:看了@sam_X的博客,就复制了过来,以作备用。

import matplotlib
matplotlib.use('Agg')

结果:已经解决

E:\ProgramData\Anaconda3\python.exe F:/PythonWork/paddle/linearRegression/housing.py


Figure(640x480)
train cost, Step 0, Cost 693.315735
Figure(640x480)
test cost, Step 0, Cost 691.099548
Figure(640x480)
train cost, Step 10, Cost 668.565979
Figure(640x480)
train cost, Step 20, Cost 654.391113
Figure(640x480)
train cost, Step 30, Cost 706.246338

Process finished with exit code 0

你可能感兴趣的:(深度学习)