5

Everything works as supposed to on the Django development server. In Apache, the django app also works except when matplotlib is used. Here's the error I get:

No module named multiarray.

Exception Type: ImportError 
Exception Value: No module named multiarray 
Exception Location: /usr/share/pyshared/numpy/core/numerictypes.py in <module>, line 81 
Python Executable: /usr/bin/python 
Python Version: 2.6.4 

From the python shell, both statements work: import numpy.core.multiarray and import multiarray. Any ideas? Thanks

As I'm looking over the numpy files, I found the multiarray module, which has an extension of 'so'. My guess, is that mod_python is not reading these files.

5
  • What happens if you do "from numpy.core.multiarray import typeinfo, ndarray, array, empty, dtype" from the python shell? Commented Apr 1, 2010 at 17:33
  • that works fine. no error messages. Commented Apr 1, 2010 at 17:36
  • I seem to have a similar problem. I'm running py2.6, cherrypy, IIS, isapi_wsgi. Matplotlib works fine from the Python shell. Trying to load pyd modules (e.g. matplotlib._path) fails when called by IIS. I've checked os.environ and sys.path. Commented Apr 10, 2010 at 3:28
  • e1i45: what version of matplotlib are you running? I have 1.3.0 on Ubuntu. I have it successfully running on windows xp with matplotlib version 1.4.0rc1. Commented Apr 10, 2010 at 3:30
  • I'm running matplotlib Version 0.99.1 Commented Apr 10, 2010 at 4:39

2 Answers 2

9

Problem solved. Here's what I did.

First of all, before I was getting the import error:

"No module named multiarray."

I was getting an error like this:

": Failed to create /some/dir/.matplotlib; consider setting MPLCONFIGDIR to a writable directory for matplotlib configuration data"

By adding the pyshared folder to the PythonPath variable, this error went away and I got the import error.

So here's how I fixed it:

Removed the pyshared folder from the PythonPath variable.

Before importing the matplotlib module, add these lines:

import os
os.environ['HOME']='/some/writable/dir'

Next, before import matplotlib.pyplot or pylab, add these lines:

import matplotlib
matplotlib.use('Agg') 
# 'Agg' or whatever your backend is.

This is documented here.

That's is! It's working on python2.5 for me now. But I believe it'll work on 2.6 as well.

Sign up to request clarification or add additional context in comments.

1 Comment

on a linux system os.environ['MPLCONFIGDIR']='/tmp' also works.
1

On Win32 I solved a similar problem (not being able to load pyd modules through ISAPI_WSGI (IIS)) by downgrading from py2.6.5 to py2.5. It seems like this might be a Python bug that has been re-introduced. See for example this discussion.

1 Comment

I think you're right. I have everything working on a windows machine with python 2.5. However, Ubuntu comes with python 2.6 and makes it very very hard to downgrade to python 2.5. On top of that, you can't install mod_python if your current python version is 2.5.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.