Python web2py导入matplotlib模块失败
我不太了解web2py的Python web2py导入matplotlib模块失败,python,matplotlib,web2py,anaconda,Python,Matplotlib,Web2py,Anaconda,我不太了解web2py的custom\u import.py的工作原理。我试图从withingmathplotlib导入模块,但结果不一致 我的控制器version.py包含这些语句 def import_mathlab_cbook(): import matplotlib.cbook as cbook return "cbook.__file__ = %r" % cbook.__file__ def import_mathlab_figure(): from matp
custom\u import.py
的工作原理。我试图从withingmathplotlib
导入模块,但结果不一致
我的控制器version.py
包含这些语句
def import_mathlab_cbook():
import matplotlib.cbook as cbook
return "cbook.__file__ = %r" % cbook.__file__
def import_mathlab_figure():
from matplotlib.figure import Figure
return "Figure.__file__ = %r" % Figure.__file__
def import_mathlab_backends():
from matplotlib.backends.backend_agg import FigureCanvasAgg
return "FigureCanvasAgg.__file__ = %r" % FigureCanvasAgg.__file__
matplotlib.cbook的导入工作正常,但其他导入会产生错误
cbook.__file__ = '/opt/anaconda2/lib/python2.7/site-packages/matplotlib/cbook.py'
Traceback (most recent call last):
File "/site/web2py.2.13.4/gluon/restricted.py", line 227, in restricted
exec ccode in environment
File "/site/web2py.2.13.4/applications/plotlab/controllers/version.py", line 53, in <module>
File "/site/web2py.2.13.4/gluon/globals.py", line 412, in <lambda>
self._caller = lambda f: f()
File "/site/web2py.2.13.4/applications/plotlab/controllers/version.py", line 41, in import_mathlab_figure
from matplotlib.figure import Figure
File "/site/web2py.2.13.4/gluon/custom_import.py", line 95, in custom_importer
return base_importer(pname, globals, locals, fromlist, level)
ImportError: No module named matplotlib.figure
Traceback (most recent call last):
File "/site/web2py.2.13.4/gluon/restricted.py", line 227, in restricted
exec ccode in environment
File "/site/web2py.2.13.4/applications/plotlab/controllers/version.py", line 53, in <module>
File "/site/web2py.2.13.4/gluon/globals.py", line 412, in <lambda>
self._caller = lambda f: f()
File "/site/web2py.2.13.4/applications/plotlab/controllers/version.py", line 46, in import_mathlab_backends
from matplotlib.backends.backend_agg import FigureCanvasAgg
File "/site/web2py.2.13.4/gluon/custom_import.py", line 95, in custom_importer
return base_importer(pname, globals, locals, fromlist, level)
ImportError: No module named matplotlib.backends.backend_agg
我正在运行Python 2.7.11 | Anaconda 2.4.1(64位)|(默认值,2015年12月6日,18:08:32)
和web2pyVersion 2.13.4-stable+timestamp.2015.12.26.04.59
我知道有一个类似的问题,但是这个问题的答案还没有被接受。我还尝试复制web2py应用程序模块目录下的
matplotlib
目录,但是我得到了importorror:libpng16.so.16:无法打开共享对象文件:没有这样的文件或目录
。什么是cbook.\uuuuu file.\uuuuu
和matplotlib.figure.\uuu file.\uuuuuu
在命令行导入中,它们只是用来演示文件从何处导入。这些方法是为诊断目的而编写的。原始代码在文件开头只有3条导入语句。我认为这可能有助于其他人分析您的问题。我还尝试复制web2py应用程序模块目录下的matplotlib
目录,但是我得到了importorror:libpng16.so.16:无法打开共享对象文件:没有这样的文件或目录
。什么是cbook.\uuuuu file.\uuuuu
和matplotlib.figure.\uuu file.\uuuuuu
在命令行导入中,它们只是用来演示文件从何处导入。这些方法是为诊断目的而编写的。原始代码在文件的开头有3条导入语句。我认为这可能有助于其他人分析您的问题。
# python web2py.py -S welcome -P
web2py Web Framework
Created by Massimo Di Pierro, Copyright 2007-2016
Version 2.13.4-stable+timestamp.2015.12.26.04.59.39
Database drivers available: sqlite3, imaplib, pymysql, pg8000
Python 2.7.11 |Anaconda 2.4.1 (64-bit)| (default, Dec 6 2015, 18:08:32)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-1)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
(InteractiveConsole)
>>>
>>> import matplotlib.cbook as cbook
>>>
>>> from matplotlib.figure import Figure
>>>
>>> from matplotlib.backends.backend_agg import FigureCanvasAgg