Ticket #7659 (new defect)

Opened 2 years ago

Last modified 1 year ago

Problem with tracmetrix upgrading 0.11 to 0.12

Reported by: anonymous Assigned to: rjollos
Priority: normal Component: TracMetrixPlugin
Severity: normal Keywords:
Cc: Trac Release: 0.11

Description

I started with trac 0.11 and a working tracmetrix plugin running on ubuntu with apache and postgresSQL.

I have successfully upgraded trac to 0.12 and started installing the tracmetrix plugin.

Installation of pythin-matlablib and python-numpy and version 0.12 of the plugin went ok without reporting errors.

I then enabled the plugin and restarted apache, but trac-admin <project> upgrade reported the database was already up to date, but the plugin was not active.

Trac is running normally but without the dashboard menu item and on the admin page, I only have a setting for TracMetrixSetupParticipant.

I have also created a clean install of trac 0.12 and this plugin installed without error and with a working dashboard. The admin page here has all settings available.

Attachments

Change History

09/09/10 11:30:42 changed by anonymous

Trac.log file contains the following entries:-

2010-09-09 10:27:02,063 Trac[loader] ERROR: Skipping "tracmetrixplugin.mdashboard = tracmetrixplugin.mdashboard": 
Traceback (most recent call last):
  File "/usr/local/lib/python2.6/dist-packages/Trac-0.12-py2.6.egg/trac/loader.py", line 70, in _load_eggs
    entry.load(require=True)
  File "/usr/local/lib/python2.6/dist-packages/setuptools-0.6c11-py2.6.egg/pkg_resources.py", line 1954, in load
    entry = __import__(self.module_name, globals(),globals(), ['__name__'])
  File "/usr/local/lib/python2.6/dist-packages/TracMetrixPlugin-0.1.8-py2.6.egg/tracmetrixplugin/mdashboard.py", line 25, in <module>
  File "/usr/lib/pymodules/python2.6/pylab.py", line 1, in <module>
    from matplotlib.pylab import *
  File "/usr/lib/pymodules/python2.6/matplotlib/__init__.py", line 711, in <module>
    rcParams = rc_params()
  File "/usr/lib/pymodules/python2.6/matplotlib/__init__.py", line 629, in rc_params
    fname = matplotlib_fname()
  File "/usr/lib/pymodules/python2.6/matplotlib/__init__.py", line 567, in matplotlib_fname
    fname = os.path.join(get_configdir(), 'matplotlibrc')
  File "/usr/lib/pymodules/python2.6/matplotlib/__init__.py", line 240, in wrapper
    ret = func(*args, **kwargs)
  File "/usr/lib/pymodules/python2.6/matplotlib/__init__.py", line 439, in _get_configdir
    raise RuntimeError("Failed to create %s/.matplotlib; consider setting MPLCONFIGDIR to a writable directory for matplotlib configuration data"%h)
RuntimeError: Failed to create /var/www/.matplotlib; consider setting MPLCONFIGDIR to a writable directory for matplotlib configuration data)
2010-09-09 10:27:02,073 Trac[loader] ERROR: Skipping "tracmetrixplugin.model = tracmetrixplugin.model": 
Traceback (most recent call last):
  File "/usr/local/lib/python2.6/dist-packages/Trac-0.12-py2.6.egg/trac/loader.py", line 70, in _load_eggs
    entry.load(require=True)
  File "/usr/local/lib/python2.6/dist-packages/setuptools-0.6c11-py2.6.egg/pkg_resources.py", line 1954, in load
    entry = __import__(self.module_name, globals(),globals(), ['__name__'])
  File "/usr/local/lib/python2.6/dist-packages/TracMetrixPlugin-0.1.8-py2.6.egg/tracmetrixplugin/model.py", line 31, in <module>
  File "/usr/lib/pymodules/python2.6/pylab.py", line 1, in <module>
    from matplotlib.pylab import *
  File "/usr/lib/pymodules/python2.6/matplotlib/pylab.py", line 206, in <module>
    from matplotlib import mpl  # pulls in most modules
  File "/usr/lib/pymodules/python2.6/matplotlib/mpl.py", line 1, in <module>
    from matplotlib import artist
  File "/usr/lib/pymodules/python2.6/matplotlib/artist.py", line 4, in <module>
    import matplotlib.cbook as cbook
AttributeError: 'module' object has no attribute 'cbook')
2010-09-09 10:27:02,082 Trac[loader] ERROR: Skipping "tracmetrixplugin.web_ui = tracmetrixplugin.web_ui": 
Traceback (most recent call last):
  File "/usr/local/lib/python2.6/dist-packages/Trac-0.12-py2.6.egg/trac/loader.py", line 70, in _load_eggs
    entry.load(require=True)
  File "/usr/local/lib/python2.6/dist-packages/setuptools-0.6c11-py2.6.egg/pkg_resources.py", line 1954, in load
    entry = __import__(self.module_name, globals(),globals(), ['__name__'])
  File "/usr/local/lib/python2.6/dist-packages/TracMetrixPlugin-0.1.8-py2.6.egg/tracmetrixplugin/web_ui.py", line 33, in <module>
  File "/usr/local/lib/python2.6/dist-packages/TracMetrixPlugin-0.1.8-py2.6.egg/tracmetrixplugin/model.py", line 31, in <module>
  File "/usr/lib/pymodules/python2.6/pylab.py", line 1, in <module>
    from matplotlib.pylab import *
  File "/usr/lib/pymodules/python2.6/matplotlib/pylab.py", line 206, in <module>
    from matplotlib import mpl  # pulls in most modules
  File "/usr/lib/pymodules/python2.6/matplotlib/mpl.py", line 1, in <module>
    from matplotlib import artist
  File "/usr/lib/pymodules/python2.6/matplotlib/artist.py", line 4, in <module>
    import matplotlib.cbook as cbook
AttributeError: 'module' object has no attribute 'cbook')

09/23/10 18:25:55 changed by william@datacraftdesign.com

I've got the same problem. Did you find an answer/workaround for this?

10/08/10 09:13:05 changed by anonymous

any solution? thanks

(follow-up: ↓ 5 ) 10/08/10 09:54:49 changed by anonymous

Try this, it works for me.

mkdir /var/www/.matplotlib chown apache.apache /var/www/.matplotlib

(in reply to: ↑ 4 ; follow-up: ↓ 6 ) 10/28/10 01:05:26 changed by anonymous

Replying to anonymous:

Try this, it works for me. mkdir /var/www/.matplotlib chown apache.apache /var/www/.matplotlib

Any update? I have the same problem as the original reporter.

(in reply to: ↑ 5 ; follow-up: ↓ 12 ) 11/02/10 21:51:38 changed by anonymous

I reported the same problem on 10/28/10.

With further investigation I have found a code fix and a work-around for this problem. I noticed on my install that I was getting errors like the following:

2010-11-02 13:39:23,557 Trac[loader] ERROR: Skipping "tracmetrixplugin.mdashboard = tracmetrixplugin.mdashboard": 
Traceback (most recent call last):
  File "build/bdist.linux-i686/egg/trac/loader.py", line 70, in _load_eggs
    entry.load(require=True)
  File "/usr/local/lib/python2.6/site-packages/setuptools-0.6c11-py2.6.egg/pkg_resources.py", line 1954, in load
    entry = __import__(self.module_name, globals(),globals(), ['__name__'])
  File "build/bdist.linux-i686/egg/tracmetrixplugin/mdashboard.py", line 25, in <module>
  File "/usr/lib/python2.6/site-packages/pylab.py", line 1, in <module>
    from matplotlib.pylab import *
  File "/usr/lib/python2.6/site-packages/matplotlib/pylab.py", line 247, in <module>
    from matplotlib.pyplot import *
  File "/usr/lib/python2.6/site-packages/matplotlib/pyplot.py", line 78, in <module>
    new_figure_manager, draw_if_interactive, show = pylab_setup()
  File "/usr/lib/python2.6/site-packages/matplotlib/backends/__init__.py", line 25, in pylab_setup
    globals(),locals(),[backend_name])
  File "/usr/lib/python2.6/site-packages/matplotlib/backends/backend_gtkagg.py", line 10, in <module>
    from matplotlib.backends.backend_gtk import gtk, FigureManagerGTK, FigureCanvasGTK,\
  File "/usr/lib/python2.6/site-packages/matplotlib/backends/backend_gtk.py", line 44, in <module>
    cursors.MOVE          : gdk.Cursor(gdk.FLEUR),
RuntimeError: could not create GdkCursor object)
2010-11-02 13:39:23,557 Trac[loader] DEBUG: Loading tracmetrixplugin.model from /usr/local/lib/python2.6/site-packages/TracMetrixPlugin-0.1.8-py2.6.egg
2010-11-02 13:39:23,568 Trac[loader] ERROR: Skipping "tracmetrixplugin.model = tracmetrixplugin.model": 
Traceback (most recent call last):
  File "build/bdist.linux-i686/egg/trac/loader.py", line 70, in _load_eggs
    entry.load(require=True)
  File "/usr/local/lib/python2.6/site-packages/setuptools-0.6c11-py2.6.egg/pkg_resources.py", line 1954, in load
    entry = __import__(self.module_name, globals(),globals(), ['__name__'])
  File "build/bdist.linux-i686/egg/tracmetrixplugin/model.py", line 31, in <module>
  File "/usr/lib/python2.6/site-packages/pylab.py", line 1, in <module>
    from matplotlib.pylab import *
  File "/usr/lib/python2.6/site-packages/matplotlib/pylab.py", line 247, in <module>
    from matplotlib.pyplot import *
  File "/usr/lib/python2.6/site-packages/matplotlib/pyplot.py", line 78, in <module>
    new_figure_manager, draw_if_interactive, show = pylab_setup()
  File "/usr/lib/python2.6/site-packages/matplotlib/backends/__init__.py", line 25, in pylab_setup
    globals(),locals(),[backend_name])
  File "/usr/lib/python2.6/site-packages/matplotlib/backends/backend_gtkagg.py", line 10, in <module>
    from matplotlib.backends.backend_gtk import gtk, FigureManagerGTK, FigureCanvasGTK,\
  File "/usr/lib/python2.6/site-packages/matplotlib/backends/backend_gtk.py", line 44, in <module>
    cursors.MOVE          : gdk.Cursor(gdk.FLEUR),
RuntimeError: could not create GdkCursor object)
2010-11-02 13:39:23,569 Trac[loader] DEBUG: Loading tracmetrixplugin.web_ui from /usr/local/lib/python2.6/site-packages/TracMetrixPlugin-0.1.8-py2.6.egg
2010-11-02 13:39:23,580 Trac[loader] ERROR: Skipping "tracmetrixplugin.web_ui = tracmetrixplugin.web_ui": 
Traceback (most recent call last):
  File "build/bdist.linux-i686/egg/trac/loader.py", line 70, in _load_eggs
    entry.load(require=True)
  File "/usr/local/lib/python2.6/site-packages/setuptools-0.6c11-py2.6.egg/pkg_resources.py", line 1954, in load
    entry = __import__(self.module_name, globals(),globals(), ['__name__'])
  File "build/bdist.linux-i686/egg/tracmetrixplugin/web_ui.py", line 33, in <module>
  File "build/bdist.linux-i686/egg/tracmetrixplugin/model.py", line 31, in <module>
  File "/usr/lib/python2.6/site-packages/pylab.py", line 1, in <module>
    from matplotlib.pylab import *
  File "/usr/lib/python2.6/site-packages/matplotlib/pylab.py", line 247, in <module>
    from matplotlib.pyplot import *
  File "/usr/lib/python2.6/site-packages/matplotlib/pyplot.py", line 78, in <module>
    new_figure_manager, draw_if_interactive, show = pylab_setup()
  File "/usr/lib/python2.6/site-packages/matplotlib/backends/__init__.py", line 25, in pylab_setup
    globals(),locals(),[backend_name])
  File "/usr/lib/python2.6/site-packages/matplotlib/backends/backend_gtkagg.py", line 10, in <module>
    from matplotlib.backends.backend_gtk import gtk, FigureManagerGTK, FigureCanvasGTK,\
  File "/usr/lib/python2.6/site-packages/matplotlib/backends/backend_gtk.py", line 44, in <module>
    cursors.MOVE          : gdk.Cursor(gdk.FLEUR),
RuntimeError: could not create GdkCursor object)

Investigating into matplotlib I found a suggestion that this error is related to running a matplotlib backend that depends on X11 and GDK running. This problem can be fixed in the code for tracmetrix by explicitly setting the matplotlib backend to the "Agg" backend. This change should probably be made in the tracmetrix codebase.

To immediately solve my problem without changing the tracmetrix code I found that I could use the matplotlibrc file stored in PYTHON_SITE_PACKAGES/matplotlib/mpl-data to set the default matplotlib backend on my system. My server runs headless so defaulting to a non-GUI backend works for my use cases.

11/03/10 11:36:29 changed by william@datacraftdesign.com

It doesn't look like any of these things help.

Looking into the file it has a problem with:

    configdir = os.environ.get('MPLCONFIGDIR')
    if configdir is not None:
        if not _is_writable_dir(configdir):
            raise RuntimeError('Could not write to MPLCONFIGDIR="%s"'%configdir)
        return configdir

    h = get_home()
    p = os.path.join(get_home(), '.matplotlib')

    if os.path.exists(p):
        if not _is_writable_dir(p):
            raise RuntimeError("'%s' is not a writable dir; you must set %s/.matplotlib to be a writable dir.  You can also set environment variable MPLCONFIGDIR to any writable directory where you want matplotlib data stored "% (h, h))
    else:
        if not _is_writable_dir(h):
            raise RuntimeError("Failed to create %s/.matplotlib; consider setting MPLCONFIGDIR to a writable directory for matplotlib configuration data"%h)

        os.mkdir(p)

    return p

It seems that it is running but not picking up things from the environment -

When I open up python and run:

>>> os.environ.get('MPLCONFIGDIR')
'/var/lib/matlab'

But the error I get is "Failed to create /root/.matplotlib;"

 Failed to create /root/.matplotlib; 

So it has skipped over that bit of code because it doesn't reckon that it has any permissions to that directory. However if I actually look at those permissions:

# ls /var/lib/matlab/ -la
total 36
drwxrwxrwx  4 apache apache  4096 Nov  3 09:15 .
drwxr-xr-x 24 root   root    4096 Sep 23 17:11 ..
drwxrwxrwx  2 apache apache  4096 Nov  3 09:15 .matplotlib
-rwxrwxrwx  1 apache apache 19611 Sep 24 10:16 fontList.cache
drwxrwxrwx  2 apache apache  4096 Sep 24 10:16 tex.cache

How does that make any sense?


So I fixed it just by hard coding the configdir = /var/lib/matlab and it seems to work now. It seems like it isn't picking up my environment variables.

11/23/10 17:41:16 changed by anonymous

I've Trac 0.12.1 running on Ubuntu 10.04.

The environment variable probably needs to be set in the trac CGI script or similar, like this:

# mkdir /var/cache/apache2/matplotlib
# chown www-data: /var/cache/apache2/matplotlib

# rcsdiff -u -r1.2 /var/lib/trac/cgi-bin/trac.wsgi 
===================================================================
RCS file: /var/lib/trac/cgi-bin/RCS/trac.wsgi,v
retrieving revision 1.2
diff -u -r1.2 /var/lib/trac/cgi-bin/trac.wsgi
--- /var/lib/trac/cgi-bin/trac.wsgi     2010/11/02 10:04:14     1.2
+++ /var/lib/trac/cgi-bin/trac.wsgi     2010/11/23 16:03:03
@@ -19,6 +19,7 @@
 def application(environ, start_request):
     os.environ['TRAC_ENV_PARENT_DIR'] = '/usr/local/lib/trac'
     os.environ['PYTHON_EGG_CACHE'] = '/var/cache/apache2/python_egg_cache'
+    os.environ['MPLCONFIGDIR'] = '/var/cache/apache2/matplotlib'
 

Also I needed to change the matplotlib backend as described in comment:6

# rcsdiff -u -r1.1 /etc/matplotlibrc 
===================================================================
RCS file: /etc/RCS/matplotlibrc,v
retrieving revision 1.1
diff -u -r1.1 /etc/matplotlibrc
--- /etc/matplotlibrc   2010/02/06 18:06:05     1.1
+++ /etc/matplotlibrc   2010/11/23 15:43:20
@@ -28,7 +28,7 @@
 # You can also deploy your own backend outside of matplotlib by
 # referring to the module name (which must be in the PYTHONPATH) as
 # 'module://my_backend'
-backend      : TkAgg
+backend      : Agg
 
 # if you are runing pyplot inside a GUI and your backend choice
 # conflicts, we will automatically try and find a compatible one for

Finally the tracmetrix plugin loaded and the pdashboard can be selected, but still no graphic is visible.

11/23/10 18:43:29 changed by anonymous

Using YUI 2.8.2r1 (locally installed to avoid problems/warnings with the https server), I needed to add the inclusion of swf-min.js; same for pdashboard.html

--- ~/mikkorantalainen-tracmetrixplugin-e668c5e/0.12/tracmetrixplugin/templates/mdashboard.html     2010-11-11 07:10:36.000000000 +0100
+++ ./mdashboard.html   2010-11-23 18:27:51.400818584 +0100
@@ -16,6 +16,7 @@
        <!-- OPTIONAL: Connection (enables XHR) --> 
        <script type="text/javascript" src="${yui_base_url}/build/connection/connection-min.js"></script> 
        <!-- Source files --> 
+       <script type="text/javascript" src="${yui_base_url}/build/swf/swf-min.js"></script> 
        <script type="text/javascript" src="${yui_base_url}/build/charts/charts-min.js"></script> 
        <script type="text/javascript">YAHOO.widget.Chart.SWFURL = "${yui_base_url}/build/charts/assets/charts.swf"; </script>
     <script type="text/javascript">

12/07/10 01:58:55 changed by rjollos

#4845 may help with the issues encountered here.

12/08/10 09:10:01 changed by rjollos

Could someone that was experiencing these problems try again with the latest 0.12 branch and see if the issue has been fixed? I have some reason to believe it may have been.

(in reply to: ↑ 6 ) 01/18/11 20:14:43 changed by anonymous

I was spinning my wheels and this comment was my solution, changing my backend to Agg.


Add/Change #7659 (Problem with tracmetrix upgrading 0.11 to 0.12)




Change Properties
Action