Hi Graham,

Thanks for your tips! It works now.

I had to comment the line WSGIPythonHome /usr/bin/python2.6 as you said! =)

Thank you!

Best regards,
Patrícia Sousa

On Sun, Mar 6, 2011 at 8:26 PM, Graham Dumpleton <[email protected]
> wrote:

> On 7 March 2011 00:22, Patricia Sousa <[email protected]> wrote:
> > Hi,
> >
> > I installed mod_wsgi module in my virtual machine and it works fine, I
> > received a "Hello world!" message from myapp.wsgi script.
> >
> > Now I want to import some modules in the wsgi script and one of them
> > is the lxml module. The goal of my project is to return one XML file
> > as a result. It is only when I import the lxml module that mod_wsgi
> > crashed.
> >
> > I did some research on the Internet and introduced the line
> > "WSGIApplicationGroup %{GLOBAL}" in the httpd.conf file, but that
> > didn't solve the problem. The error log has the following:
> >
> >
> > [Sun Mar 06 12:28:00 2011] [error] [client 10.249.0.102] mod_wsgi
> > (pid=12529): Target WSGI script '/var/www/html/wsgi-scripts/
> > myapp.wsgi' cannot be loaded as Python module.
> > [Sun Mar 06 12:28:00 2011] [error] [client 10.249.0.102] mod_wsgi
> > (pid=12529): Exception occurred processing WSGI script '/var/www/html/
> > wsgi-scripts/myapp.wsgi'.
> > [Sun Mar 06 12:28:00 2011] [error] Traceback (most recent call last):
> > [Sun Mar 06 12:28:00 2011] [error]   File "/var/www/html/wsgi-scripts/
> > myapp.wsgi", line 8, in <module>
> > [Sun Mar 06 12:28:00 2011] [error]     import lixo
> > [Sun Mar 06 12:28:00 2011] [error]   File "/var/www/html/wsgi-scripts/
> > lixo.py", line 2, in <module>
> > [Sun Mar 06 12:28:00 2011] [error]     from xml.etree.ElementTree
> > import Element, SubElement, tostring, XML
> > [Sun Mar 06 12:28:00 2011] [error] ImportError: No module named
> > xml.etree.ElementTree
> >
> > As I thought that the problem was in python not knowing the location
> > of lxml, I added the following code to my myapp.wsgi file:
> >
> >
> > sys.path.insert(0, '/var/www/html/wsgi-scripts') # where I have the
> > python and wsgi files
> > sys.path.insert(1, '/usr/lib/python2.6/site-packages/') # Where the
> > python files are
>
> You should need to do the latter.
>
> > However, I still get the same error in the log...
> > I'm going crazy with this error. Does anyone know what to do to make
> > mod_wsgi work with lxml?
> >
> > Thank you,
> >
> > Best regards,
> > Patrícia Sousa
> >
> >
> > PS: Some relevant files follows
> >
> > httpd.conf:
> >
> >
> > LoadModule wsgi_module modules/mod_wsgi.so
> > AddHandler wsgi-script .wsgi .py
> > WSGIPythonHome /usr/bin/python2.6
>
> Again, you should not need to set WSGIPythonHome and that value for it
> is wrong anyway. It is not meant to be the path to the executable.
>
> Also be aware that you cannot use WSGIPythonHome to force mod_wsgi to
> use a different Python version than what it was compiled against.
>
> Now, as:
>
>  http://docs.python.org/library/xml.etree.elementtree.html
>
> says that 'xml.etree.ElementTree' was only added in Python 2.5, am
> wondering if your mod_wsgi is actually compiled against and using
> Python 2.4.
>
> Do the checks in sections starting at:
>
>
> http://code.google.com/p/modwsgi/wiki/CheckingYourInstallation#Python_Shared_Library
>
> and validate what version of Python the mod_wsgi package is compiled
> against and then using at run time.
>
> You may have to de install mod_wsgi compiled for Python 2.4 and
> reinstall that for Python 2.6.
>
> Graham
>
> > WSGIApplicationGroup %{GLOBAL}
> >
> > <Directory /var/www/html/wsgi-scripts>
> >  Options Indexes FollowSymLinks MultiViews
> >  Options +ExecCGI
> >  AllowOverride None
> >  Order allow,deny
> >  allow from all
> > </Directory>
> >
> >
> > myapp.wsgi:
> >
> > #!/usr/bin/python2.6
> >
> > import sys
> >
> > sys.path.insert(0, '/var/www/html/wsgi-scripts')
> > sys.path.insert(1, '/usr/lib/python2.6/site-packages/')
> >
> > import lixo # o ficheiro está na pasta /var/www/html/wsgi-scripts
> >
> > def application(environ, start_response):
> >    status = '200 OK'
> >    output = 'Hello World!'
> >
> >    response_headers = [('Content-type', 'text/plain'),
> >                        ('Content-Length', str(len(output)))]
> >    start_response(status, response_headers)
> >
> >    print >> sys.stderr, 'sys.prefix = %s' % repr(sys.prefix)
> >    print >> sys.stderr, 'sys.path = %s' % repr(sys.path)
> >
> >    return [output]
> >
> >
> > lixo.py:
> >
> > #!/usr/bin/python2.6
> >
> > # Even if i comment this next line the error appears on the second
> > import
> > from xml.etree.ElementTree import Element, SubElement, tostring, XML
> > from lxml import etree
> >
> > xml2 = '<oai_dc:dc xmlns:dc="http://purl.org/dc/elements/1.1/";
> > xmlns:oai_dc="http://www.openarchives.org/OAI/2.0/
> > oai_dc/"><dc:identifier>foo:11</dc:identifier><dc:subject>fcrepo</
> > dc:subject><dc:subject>unittest</dc:subject><dc:description>bla</
> > dc:description><dc:description>A test object from the fcrepo unittest</
> > dc:description><dc:title>My First Test Object</dc:title></oai_dc:dc>'
> >
> > def createHeaderXML():
> >  NS = 'http://www.w3.org/2001/XMLSchema-instance'
> >  TREE = '{%s}' % NS
> >  NSMAP = {None: NS}
> >  location_attribute = '{%s}schemaLocation' % NS
> >  root = etree.Element('OAI-PMH', attrib={location_attribute: 'http://
> >
> www.openarchives.org/OAI/2.0/OAI-PMHhttp://www.openarchives.org/OAI/2.0/OAI-PMH.xsd'<http://www.openarchives.org/OAI/2.0/OAI-PMHhttp://www.openarchives.org/OAI/2.0/OAI-PMH.xsd%27>
> })
> >
> >  return root
> >
> > def createNoResultXML():
> >  root = etree.Element('results')
> >  result = etree.SubElement(root, "result")
> >  result.text = "Without results"
> >  return root
> >
> > cabe = createNoResultXML()
> > print etree.tostring(cabe, pretty_print=True)
> >
> > --
> > You received this message because you are subscribed to the Google Groups
> "modwsgi" group.
> > To post to this group, send email to [email protected].
> > To unsubscribe from this group, send email to
> [email protected].
> > For more options, visit this group at
> http://groups.google.com/group/modwsgi?hl=en.
> >
> >
>
> --
> You received this message because you are subscribed to the Google Groups
> "modwsgi" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected].
> For more options, visit this group at
> http://groups.google.com/group/modwsgi?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"modwsgi" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/modwsgi?hl=en.

Reply via email to