我有一个以:
开头的python程序from optparse import OptionParser
import math
#import wx
import os
import numpy as np
import matplotlib.pyplot as plt
from pylab import *
from numpy import *
import scipy as scipy
from scipy import *
from scipy import constants
import scipy.signal as signal
import matplotlib.pyplot as plt
当我尝试用php打开它时,它给了我错误。 我已经google了,显然如果我在导入pylab或pyplot之前这样做了:
import matplotlib
matplotlib.use('Agg')
import matplotlib.pyplot as plt
问题应该解决。但我得到的错误是:
/usr/lib/pymodules/python2.7/matplotlib/__init__.py:923: UserWarning: This call to matplotlib.use() has no effect
because the the backend has already been chosen;
matplotlib.use() must be called *before* pylab, matplotlib.pyplot,
or matplotlib.backends is imported for the first time
知道发生了什么吗?
答案 0 :(得分:0)
默认后端在matplotlibrc
文件中指定 - 您可以尝试在那里进行更改。
也许你运行python的环境可能已经导入matplotlib并将后端指定为配置的一部分。另外,some帖子表明可能需要以下内容:
os.environ[ 'MPLCONFIGDIR' ] = '/tmp/'