1
使用maptlotlib我有一个开头python程序:麻烦Web应用程序服务器(PHP)
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
任何想法发生了什么事?
你如何建议我改变后端?我应该怎样改变它? – Jack 2015-04-02 18:03:09
尝试'locate',通常可以在etc中找到示例matplotlibrc,也许在.config/matplotlib/matplotlibrc中默认文件。同样在http://matplotlib.org/users/customizing.html。 matplotlib将优先在本地目录中使用'.matplotlibrc'的版本来定义后端。如果python的建议是'Agg' for php,请尝试更改为此。但是,听起来像后端可能会在从PHP调用时在其他地方指定。 http://texnological.blogspot.co.uk/2013/01/how-to-execute-python-matplolib-pylab.html中的其他帖子无法帮助吗? – 2015-04-02 21:40:58