我有一个以以下内容开头的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打开它时,它给了我错误。我已经谷歌搜索并且显然如果我在导入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
知道发生了什么吗?
默认后端在matplotlibrc
文件中指定-您可以尝试在此处进行更改。
也可能是您正在运行python的任何环境都可能已经导入matplotlib并指定了后端作为配置的一部分。另外,一些帖子建议可能需要以下行:
os.environ[ 'MPLCONFIGDIR' ] = '/tmp/'
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句