Alain Tesio
alain at onesite.org
Thu Mar 7 12:55:25 EST 2002
On Thu, 7 Mar 2002 11:37:10 -0000 "alf" <alf at proweb.co.uk> wrote: > Hi, > > I'm having a great time with mod_python, it's doing everything I want so far > > except this : > > I can import most modules re, string, os, sys, even my own modules but for > some reason when I try and import md5 or MySQLdb I get : > ImportError: No module named md5 > > When I use the python console I get the expected : > Python 2.2 (#1, Feb 12 2002, 21:26:35) > [GCC 2.95.2 19991024 (release)] on freebsd4T > ype "help", "copyright", "credits" or "license" for more information. > >>> from mod_python import apache > Traceback (most recent call last): File "<stdin>", line 1, in ? > File "/usr/local/lib/python2.2/site-packages/mod_python/apache.py", line 55, > in ? > import _apache > ImportError: No module named _apache > >>> import md5 > >>> > > I've ended up writing a routine : > > def getMD5(txt) : > md5fn = "/tmp/md5" + `getpid()` > system("echo -n \"" + txt + "\" | md5 > " + md5fn) > md5f = open(md5fn) > md5l = md5f.readlines() > md5f.close() > unlink(md5fn) > return md5l[0] > > presumably it's something to do with md5 & MySQLdb being a c external > > any solution? > > cheers > > Matt Hi, I can import MySQLdb fine, maybe you can add the path to the module in sys.path Btw in your function, you could also use a pipe instead of a temporary file. Alain
|