On 5 December 2010 08:08, Matt Wilson <[email protected]> wrote:
> I'm hoping to run my webapp in Apache, but it seems like I can't
> import ctypes in my code.
>
> I wrote this trivial wsgi app to short the problem:
>
> def application(environ, start_response):
>
> import ctypes # this crashes
>
> status = '200 OK'
> output = 'Hello World!'
>
> response_headers = [('Content-type', 'text/plain'),
> ('Content-Length', str(len(output)))]
>
> start_response(status, response_headers)
>
> return [output]
>
> Then I set up this virtual host:
>
> <VirtualHost *:80>
>
> ServerName pitz.sprout.tplus1.com
>
> ServerAdmin webmas...@localhost
>
> DocumentRoot /home/matt/checkouts/pitz/pitz/static
>
> # Possible values include: debug, info, notice, warn, error, crit,
> # alert, emerg.
> LogLevel info
>
> CustomLog /var/log/apache2/pitz-access.log combined
> ErrorLog /var/log/apache2/pitz-error.log
> ServerSignature On
>
> <Directory /home/matt/checkoutz/pitz/apache-nonsense>
> Order allow,deny
> Allow from all
> </Directory>
>
> WSGIProcessGroup pitz
> WSGIApplicationGroup %{GLOBAL}
>
> WSGIScriptAlias / /home/matt/checkouts/pitz/apache-nonsense/
> myapp.wsgi
>
> RewriteEngine on
> RewriteRule ^/static/(.*) /home/matt/checkouts/pitz/pitz/static/$1
> [last]
> RewriteRule ^/favicon.ico /home/matt/checkouts/pitz/pitz/static/
> favicon.ico [last]
>
> </VirtualHost>
>
> And I have this stuff too:
>
> WSGIPythonHome /home/matt/.virtualenvs/pitz
You should not set WSGIPythonHome unless you really need to. Not often
you would want to point it at a virtual environment root.
> WSGIPythonPath /home/matt/.virtualenvs/pitz/lib/python2.6/site-
> packages
This will have no affect as you are delegating to a daemon process.
WSGIPythonPath only works for embedded mode.
If you really need to do this for daemon mode, use python-path option
to WSGIDaemonProcess instead.
> WSGIDaemonProcess pitz processes=1 threads=10 display-name=%{GROUP}
Don't set processes=1 option. A single process is the default anyway,
but setting 'processes' option, no matter if even set to '1', has side
effect of setting 'wsgi.multiprocess' to True in WSGI environment,
something which for single process you would only want to do in
certain circumstances.
> When I restart apache, and then hit http://pitz.sprout.tplus1.com/, I
> get a 500 back, and this error is in my errors log file:
>
> [Sat Dec 04 15:58:01 2010] [error] [client 127.0.1.1] mod_wsgi
> (pid=9678): Exception occurred processing WSGI script '/home/matt/
> checkouts/pitz/apache-nonsense
> [Sat Dec 04 15:58:01 2010] [error] [client 127.0.1.1] Traceback (most
> recent call last):
> [Sat Dec 04 15:58:01 2010] [error] [client 127.0.1.1] File "/home/
> matt/checkouts/pitz/apache-nonsense/myapp.wsgi", line 5, in
> application
> [Sat Dec 04 15:58:01 2010] [error] [client 127.0.1.1] import
> ctypes
> [Sat Dec 04 15:58:01 2010] [error] [client 127.0.1.1] File "/usr/
> local/lib/python2.6/ctypes/__init__.py", line 10, in <module>
> [Sat Dec 04 15:58:01 2010] [error] [client 127.0.1.1] from _ctypes
> import Union, Structure, Array
> [Sat Dec 04 15:58:01 2010] [error] [client 127.0.1.1] ImportError: /
> usr/local/lib/python2.6/lib-dynload/_ctypes.so: undefined symbol:
> PyUnicodeUCS2_FromEncoded
> (END)
>
> I'm running ubuntu 10.0.4 LTS, I installed the stock apache2:
>
> $ apache2 -version
> Server version: Apache/2.2.14 (Ubuntu)
> Server built: Nov 18 2010 21:17:19
>
> The mod_wsgi version I'm running is this 2.8 (it's the one I got from
> ubuntu).
>
> I just noticed you're up to version 3.3 -- maybe this problem has
> already been fixed, or maybe there's something wrong with my
> configuration. Anyhow, I could really use a little help.
Not known to be an issue with mod_wsgi.
Instead, it has always been an issue with mod_wsgi being compiled
against, using different Python library, than the virtual environment
that mod_wsgi is being pointed at by WSGIPythonHome directive.
You need to verify what installation of Python mod_wsgi was compiled
against and what it is using at run time. See:
http://code.google.com/p/modwsgi/wiki/CheckingYourInstallation
In other words, mod_wsgi may be compiled against Python 2.5 but you
are trying to use Python 2.6 installation.
Sort out any such discrepancy by working it out per the referenced
documentation above.
Graham
--
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.