execfile() - change python version?

Trung Hoang thoa0025 at mail.usyd.edu.au
Fri Mar 29 22:44:27 EST 2002


running the following set of commands in a script:
    import xml.dom.minidom
    dom = xml.dom.minidom.parseString(somexmlstr)

using the above in python2.1 from my account: WORKS
using the above in python2.1 from the web: WORKS
using the above in python2.2 from my account : WORKS
using the above in python2.2 from the web : FAILS!

so im forced to used 2.1 because of xml libraries
#!/local/usr/bin/python
as aposed to
#!/local/usr/bin/python2.2

it probably does not work because of some environmental
variable not being set, which when run from the web
fails to find the SAX parser..

fast translation of tracedump:
i execute xml.dom.minidom.parseString(xmlstr) and it fails to create the SAX
reader in the xml.sax.__init__. i believe it is perhaps python can not find
the required libraries in 2.2 but able to find them in 2.1.

here is the raw tracedump:
[('/usr/cs3/thoang/lib/html/q.cgi', 43, '?', 'execfile("handle-projects.py",
namespace)'), ('handle-projects.py', 14, '?', "projects =
mods['xmlagent'].getProjects()"), ('/usr/cs3/thoang/lib/html/xmlagent.py',
16, 'getProjects', 'dom = xml.dom.minidom.parseString(datamine)'),
('/usr/local/lib/python2.2/xml/dom/minidom.py', 965, 'parseString', 'return
_doparse(pulldom.parseString, args, kwargs)'),
('/usr/local/lib/python2.2/xml/dom/minidom.py', 951, '_doparse', 'events =
apply(func, args, kwargs)'), ('/usr/local/lib/python2.2/xml/dom/pulldom.py',
340, 'parseString', 'parser = xml.sax.make_parser()'),
('/usr/local/lib/python2.2/xml/sax/__init__.py', 93, 'make_parser', 'raise
SAXReaderNotAvailable("No parsers found", None)')]

what are your thoughts?

"Peter Hansen" <peter at engcorp.com> wrote in message
news:3CA53165.E3A765A4 at engcorp.com...
> Trung Hoang wrote:
> >
> > Hi,
> >
> > i was wondering if there is a way to change which version of python
> > processing the file when execfile().
>
> No.  execfile() is basically "execute this file using the currently
> running version of Python".
>
> > i wish to use python2.2 on the main file, and python2.1 on the file
passed
> > into the argument of execfile().
>
> Don't use execfile().  Use os.system() and run the version you want
instead.
>
> > reason being: there is some sort of mis configuration error on the
server i
> > am using python on.
>
> Sounds like there must be an easier way to solve the problem.  Can
> you give more detail on this "misconfiguration error"?





More information about the Python-list mailing list