jvandal / modwsgi

Automatically exported from code.google.com/p/modwsgi
0 stars 0 forks source link

Error of Import matplotlib #170

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
Hello everyone

I am using Django to develop my webapp.
When I have done my project, I deploy to Apache Http Server with mod_wsgi.
I try to run my webapp in Django's develop server, it's OK.
But it always have error when importing matplotlib to wsgi.
It seems to some bug between mod_wsgi and matplotlib.
I don't know what thing cause error, wish someone know it!

The error is:
[Wed Nov 18 15:01:33 2009] [warn] mod_wsgi: Compiled for Python/2.6.2.
[Wed Nov 18 15:01:33 2009] [warn] mod_wsgi: Runtime using Python/2.6.4.
[Wed Nov 18 15:01:33 2009] [warn] mod_wsgi: Python module path 
'C:\\WINDOWS\\system32\\python26.zip;C:\\Python26\\Lib;C:\\Python26\\DLLs;C
:\\Python26\\Lib\\lib-tk;;C:\\wamp\\bin\\apache\\apache2.2.11\\bin'.
[Wed Nov 18 15:01:33 2009] [notice] Child 4068: Child process is running
[Wed Nov 18 15:01:33 2009] [notice] Child 4068: Acquired the start mutex.
[Wed Nov 18 15:01:33 2009] [notice] Child 4068: Starting 64 worker threads.
[Wed Nov 18 15:01:33 2009] [notice] Child 4068: Starting thread to listen 
on port 80.
[Wed Nov 18 15:01:36 2009] [error] [client 127.0.0.1] mod_wsgi (pid=4068): 
Exception occurred processing WSGI script 'C:/testwsgi.py'.
[Wed Nov 18 15:01:36 2009] [error] [client 127.0.0.1] Traceback (most 
recent call last):
[Wed Nov 18 15:01:36 2009] [error] [client 127.0.0.1]   File 
"C:/testwsgi.py", line 7, in application
[Wed Nov 18 15:01:36 2009] [error] [client 127.0.0.1]     from 
matplotlib.backends.backend_agg import FigureCanvasAgg as FigureCanvas
[Wed Nov 18 15:01:36 2009] [error] [client 127.0.0.1]   File 
"C:\\Python26\\lib\\site-packages\\matplotlib\\backends\\backend_agg.py", 
line 28, in <module>
[Wed Nov 18 15:01:36 2009] [error] [client 127.0.0.1]     from 
matplotlib.backend_bases import RendererBase,\\
[Wed Nov 18 15:01:36 2009] [error] [client 127.0.0.1]   File 
"C:\\Python26\\lib\\site-packages\\matplotlib\\backend_bases.py", line 31, 
in <module>
[Wed Nov 18 15:01:36 2009] [error] [client 127.0.0.1]     import 
matplotlib.transforms as transforms
[Wed Nov 18 15:01:36 2009] [error] [client 127.0.0.1]   File 
"C:\\Python26\\lib\\site-packages\\matplotlib\\transforms.py", line 34, in 
<module>
[Wed Nov 18 15:01:36 2009] [error] [client 127.0.0.1]     from 
matplotlib._path import affine_transform
[Wed Nov 18 15:01:36 2009] [error] [client 127.0.0.1] ImportError: DLL load 
failed: \xa7\xe4\xa4\xa3\xa8\xec\xab\xfc\xa9w\xaa\xba\xbc\xd2\xb2\xd5\xa1C

---------------------------------------
My environment is
Apache=2.2.11
Python=2.6.4
Windows XP SP2
matplotlib=0.99.1
mod_wsgi=mod_wsgi-win32-ap22py26-2.6.so

Does any one know how to solve? Many thanks.

Original issue reported on code.google.com by t5318...@gmail.com on 18 Nov 2009 at 7:15

GoogleCodeExporter commented 8 years ago
This is not the mailing list and there is no broad audience here to answer your 
question. The mailing list is at:

http://groups.google.com/group/modwsgi

Can only suggest two things and if they don't work then try the mailing list or 
even StackOverflow site, 
referencing this issue so people know what you have been told already.

First thing is to know that Apache service runs as a special user on Windows. 
That user must have read access to 
Python code files and loadable modules plus dependent DLLs. If it doesn't it 
will not be able to find them.

Second is that as Apache runs as service, it does use your user environment. 
Thus if required DLLs are not 
installed in main system DLL library directory or elsewhere then Apache will 
not be able to find them and you 
may get a DLL load error.

So, verify that Apache service user has read access to everything it needs and 
secondly that DLLs required by 
matplotlib are in location on standard DLL search paths.

Original comment by Graham.Dumpleton@gmail.com on 18 Nov 2009 at 9:02

GoogleCodeExporter commented 8 years ago
That should read:

"""Second is that as Apache runs as service, it does NOT use your user 
environment."""

Original comment by Graham.Dumpleton@gmail.com on 18 Nov 2009 at 9:05

GoogleCodeExporter commented 8 years ago
Dear Graham.Dumpleton, 

Many many thanks for your rapid response.

I have struggle for solve this problem all day.
I think the problem is the DLL file, also I find a useful reference:
http://old.nabble.com/matplotlib._path-failed-on-windows-build-for-Python-2.6-td
22963286.html

Besides, I also write a article about "How to Integrate Django with Apache
--榛果和阿帕契的整合--"(writed by mandarin),
http://docs.google.com/View?id=dfrfs8nb_1490cwwfjrkn

In this article, I use mod_wsgi to do the job. 

mod_wsgi is excellent!!

Original comment by t5318...@gmail.com on 18 Nov 2009 at 9:39

GoogleCodeExporter commented 8 years ago
If anyone has this problem, this can be solved by using FastCGI.
I have used FastCGI to run my Django application and matplotlib.
I will still to find out what cause the "DLL load error".

Original comment by t5318...@gmail.com on 19 Nov 2009 at 3:45

GoogleCodeExporter commented 8 years ago
Presumed to be environment issue with user so closing.

Original comment by Graham.Dumpleton@gmail.com on 22 Nov 2009 at 3:03