Are you running this in daemon mode? Is the application the only thing
running, be it embedded mode or daemon mode?
If you are running one application, add:
WSGIApplicationGroup %{GLOBAL}
This will force use of main interpreter, which presumably may have
already had codecs imported as part of main Python initialisation.
In other words, not working in sub interpreters perhaps as indicated
maybe by other email if seen in other embedded systems.
Graham
On 15 March 2011 16:30, Andreas Sommer <[email protected]> wrote:
> On 15.03.2011 20:51, Graham Dumpleton wrote:
>> The #python IRC channel says that yes, unicode in sys.path is okay and
>> should be converted based on file system encoding. That was qualified
>> by comment that 'it doesn't always work' as expected.
>>
>> Given that you are using a virtualenv I would suspect that maybe
>> something is broken with that. That or mod_wsgi is running against
>> different Python installation than what it was built for.
> No, both the Debian Python installation and the virtualenv are the same
> interpreter version. You can actually comment out the virtualenv lines
> from my example WSGI file and get the same codec problem. I assume that
> mod_wsgi starts up the interpreter without importing the codecs module.
> Checked this by putting the following at the very beginning of the WSGI
> file:
>
> import sys
> with open("/tmp/wsgimodules", "wb") as f: print >>f, sys.modules
>
> The outcome was a modules dict without the "codecs" module!
>
> And for completeness the output of the tests you wanted me to run:
>
> Without virtualenv activation:
>
> sys.version = '2.6.6 (r266:84292, Dec 26 2010, 22:48:11) \n[GCC 4.4.5]'
> sys.prefix = '/usr'
>
> With virtualenv (notice Unicode prefix because I inserted that into the
> sys.path):
>
> sys.version = '2.6.6 (r266:84292, Dec 26 2010, 22:48:11) \n[GCC 4.4.5]'
> sys.prefix =
> u'/var/www/django-sites/351b488d-80bb-42f0-b1bb-927aa89a1d5c/django_simple_todo_list/env'
>
> And linkage of mod_wsgi.so-2.6 which is the .so file used by my Apache
> process:
> linux-vdso.so.1 => (0x00007fff74806000)
> libpython2.6.so.1.0 => /usr/lib/libpython2.6.so.1.0 (0x00007fbd474d0000)
> libpthread.so.0 => /lib/libpthread.so.0 (0x00007fbd472b4000)
> libdl.so.2 => /lib/libdl.so.2 (0x00007fbd470af000)
> libutil.so.1 => /lib/libutil.so.1 (0x00007fbd46eac000)
> libm.so.6 => /lib/libm.so.6 (0x00007fbd46c2a000)
> libc.so.6 => /lib/libc.so.6 (0x00007fbd468c8000)
> libssl.so.0.9.8 => /usr/lib/libssl.so.0.9.8 (0x00007fbd46673000)
> libcrypto.so.0.9.8 => /usr/lib/libcrypto.so.0.9.8 (0x00007fbd462d2000)
> libz.so.1 => /usr/lib/libz.so.1 (0x00007fbd460ba000)
> /lib64/ld-linux-x86-64.so.2 (0x00007fbd47bb2000)
>
> As said above, I think not importing the "codecs" module by default is
> the problem in my eyes. So the question is should mod_wsgi always
> include this? -- you mentioned that most users use byte strings and thus
> don't need the module. I have no problem with the manual "import codecs"
> workaround, but that should get documented somewhere in the wiki.
>> Can you provide the result of doing the following tests:
>>
>> http://code.google.com/p/modwsgi/wiki/CheckingYourInstallation#Python_Shared_Library
>> http://code.google.com/p/modwsgi/wiki/CheckingYourInstallation#Python_Installation_In_Use
>>
>> Graham
>>
>> On 15 March 2011 15:40, Andreas Sommer <[email protected]>
>> wrote:
>>> On 15.03.2011 18:54, Graham Dumpleton wrote:
>>>> On 15 March 2011 06:45, Andreas Sommer <[email protected]>
>>>> wrote:
>>>>> Hi,
>>>>>
>>>>> I'm getting the exception
>>>>>
>>>>> File
>>>>> "/var/www/django-sites/351b488d-80bb-42f0-b1bb-927aa89a1d5c/wsgi_autogen.py",
>>>>> line 9, in <module>
>>>>> if os.path.exists(virtualenvDirectory + 'bin')
>>>>> File "/usr/lib/python2.6/genericpath.py", line 18, in exists
>>>>> st = os.stat(path)
>>>>> LookupError: no codec search functions registered: can't find encoding
>>>>>
>>>>> in my WSGI script (autogenerated by my program Site Deploy):
>>>>>
>>>>> import os
>>>>> import sys
>>>>>
>>>>> sys.path.insert(0,
>>>>> u'/var/www/django-sites/351b488d-80bb-42f0-b1bb-927aa89a1d5c')
>>>>>
>>>>> virtualenvDirectory =
>>>>> u'/var/www/django-sites/351b488d-80bb-42f0-b1bb-927aa89a1d5c/django_simple_todo_list/env/'
>>>> And if you don't use unicode strings in sys.path?
>>>>
>>>> I have never heard of anyone doing that and didn't know you even could
>>>> do it with Python 2.X.
>>>>
>>>> Graham
>>> Sure, using byte strings instead works fine because then Python doesn't
>>> have to decode Unicode to any filesystem encoding. But that is not a
>>> solution for me... Unicode is the way to go. It's especially important
>>> if you have special characters in some files and transfer them from one
>>> filesystem to another. Try committing a file in GIT on Windows =
>>> windows-1252, and then check it out on Linux = utf-8... GIT does not
>>> support Unicode and thus f***s up filenames.
>>>
>>> Just out of interest: It seems that mod_wsgi is Python 3 compatible -
>>> wouldn't you run into the described codecs problem with 3.x if you use
>>> Unicode strings?
>>>
>>> --
>>> 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.