You can not mix versions. You will need to use a Python 2.6 generated
virtual environment. You can't use a 2.7 version virtual environment
with mod_wsgi compiled against 2.6.

Graham

On 3 November 2011 17:27, Bastien Rocheron <[email protected]> wrote:
> So,
>
> in Python interpreter against virtual environment:
> sys.version: '2.6.6 (r266:84292, Dec 26 2010, 22:31:48) \n[GCC 4.4.5]'
> sys.prefix: '/usr'
>
> and under mod_wsgi:
>
> sys.version = '2.6.6 (r266:84292, Dec 26 2010, 22:48:11) \n[GCC 4.4.5]'
> sys.prefix = '/usr'
>
>
> lld mod_wsgi.so
> ldd: ./mod_wsgi.so: No such file or directory
>
> unset LD_LIBRARY_PATH
> lld mod_wsgi.so
> ldd: ./mod_wsgi.so: No such file or directory
>
> ldd /usr/lib/apache2/modules/mod_wsgi.so | grep libpython:
> libpython2.6.so.1.0 => /usr/lib/libpython2.6.so.1.0 (0x00007fcdd55a5000)
>
>
>
> Then in Python interpreter against virtual environment:
>
>>>> import django
> Traceback (most recent call last):
>   File "<stdin>", line 1, in <module>
> ImportError: No module named django
>
> Then under mod_wsgi when I add
> import os
>  print os.listdir('/some/path')
>
> I get ['template', 'core', 'templatetags', 'dispatch', 'db', 'contrib',
> 'conf', 'http', 'bin', '__init__.py', 'utils', 'shortcuts', 'test', 'views',
> 'forms', 'middleware'] which is the content of the django directory in the
> virtual env which path I indicated instead of /some/path.
>
> Obviously the problem here seems to be the inability to import django but I
> don't know what I should change. I should add that I created this virtual
> env on a different system (with python 2.7) where import django works
> against the virtual env (django is not installed in the system either) and
> then deployed this virtual env on the Debian.
>
> Thanks for your help.
>
>
>
> On Thu, Nov 3, 2011 at 1:40 AM, Graham Dumpleton
> <[email protected]> wrote:
>>
>> What do you get in Python interpreter run against virtual environment for:
>>
>>  import sys
>>  sys.version
>>  sys.prefix
>>
>> Similarly, under mod_wsgi as described in:
>>
>>
>>  http://code.google.com/p/modwsgi/wiki/CheckingYourInstallation#Python_Installation_In_Use
>>
>> What do you get for:
>>
>>  ldd mod_wsgi.so
>>
>> Ie. which run time libpythonX.Y.so is it finding.
>>
>>
>>  http://code.google.com/p/modwsgi/wiki/CheckingYourInstallation#Python_Shared_Library
>>
>> In Python interpreter against virtual environment run:
>>
>>  import django
>>  django.__file__
>>
>> This will be a path to a file, take the directory part of that, ie.,
>> drop __init__.py of the end, and in the same prefix/version test
>> script above under mod_wsgi add:
>>
>>  import os
>>  print os.listdir('/some/path')
>>
>> where /some/path is replaced with the directory that Django is installed
>> in.
>>
>> If that fails, it indicates Apache user doesn't have read access down
>> through all directories to where Django installed in virtual
>> environment.
>>
>> Graham
>>
>> On 3 November 2011 08:02, karme <[email protected]> wrote:
>> > Ok I thought I would try again from scratch using specific
>> > instructions but you're right let's start from an actual config and
>> > work our way from there.
>> >
>> > So I will start with what seems to be the closest configuration to
>> > what I actually want to achieve:
>> >
>> > 1. The actual Apache configuration snippets for mod_wsgi you are
>> > using:
>> >
>> > <VirtualHost someserver:80>
>> >    ServerName myvirtualhost
>> >
>> >    DocumentRoot /path/to/my/project/apache/documents
>> >
>> >    <Directory /path/to/my/project/apache/documents>
>> >    Order allow,deny
>> >    Allow from all
>> >    </Directory>
>> >
>> >    # I comment this line so the server starts in embedded mode and I
>> > get the errors in Apache error.log
>> >    # (I can't see any error in daemon mode)
>> >    #WSGIDaemonProcess django processes=2 threads=5 display-
>> > name=myproject user=myuser group=mygroup
>> >    WSGIScriptAlias / /path/to/my/project/apache/settings.wsgi
>> >
>> >    <Directory /path/to/my/project/apache>
>> >    #WSGIProcessGroup django
>> >    Order allow,deny
>> >    Allow from all
>> >    </Directory>
>> > </VirtualHost>
>> >
>> > 2. The contents of your WSGI script file:
>> >
>> > import os
>> > import sys
>> >
>> > root = os.path.join(os.path.dirname(__file__), '..')
>> > sys.path.insert(0, root)
>> >
>> > activate_this = os.path.join(root, 'bin/activate_this.py')
>> > execfile(activate_this, dict(__file__=activate_this))
>> >
>> > os.environ['DJANGO_SETTINGS_MODULE'] = 'settings'
>> >
>> > import django.core.handlers.wsgi
>> > application = django.core.handlers.wsgi.WSGIHandler()
>> >
>> >  3. Indicate how you created the virtual environment, did you use
>> >  --no-site-packages option to virtualenv.
>> >
>> > Yes I used  --no-site-packages
>> >
>> >  4. The actual error messages from the Apache error logs you are
>> >  getting showing there is a problem.
>> >
>> > With this config, the apache error log gives this output:
>> >
>> > [Wed Nov 02 21:27:14 2011] [info] mod_wsgi (pid=4658): Create
>> > interpreter 'myproject.myhost|'.
>> > [Wed Nov 02 21:27:14 2011] [info] [client IP] mod_wsgi (pid=4658,
>> > process='', application='myproject.myhost|'): Loading WSGI script '/
>> > path/to/my/project/apache/settings.wsgi'.
>> > [Wed Nov 02 21:27:14 2011] [error] [client IP] mod_wsgi (pid=4658):
>> > Target WSGI script '/path/to/my/project/apache/settings.wsgi' cannot
>> > be loaded as Python module.
>> > [Wed Nov 02 21:27:14 2011] [error] [client IP] mod_wsgi (pid=4658):
>> > Exception occurred processing WSGI script '/path/to/my/project/apache/
>> > settings.wsgi'.
>> > [Wed Nov 02 21:27:14 2011] [error] [client IP] Traceback (most recent
>> > call last):
>> > [Wed Nov 02 21:27:14 2011] [error] [client IP]   File "/path/to/my/
>> > project/apache/settings.wsgi", line 12, in <module>
>> > [Wed Nov 02 21:27:14 2011] [error] [client IP]     import
>> > django.core.handlers.wsgi
>> > [Wed Nov 02 21:27:14 2011] [error] [client IP] ImportError: No module
>> > named django.core.handlers.wsgi
>> > [Wed Nov 02 21:27:14 2011] [debug] mod_deflate.c(615): [client IP]
>> > Zlib: Compressed 538 to 325 : URL /
>> > [Wed Nov 02 21:27:14 2011] [info] mod_wsgi (pid=4663): Initializing
>> > Python.
>> > [Wed Nov 02 21:27:14 2011] [info] mod_wsgi (pid=4663): Attach
>> > interpreter ''.
>> >
>> > Another interesting thing to note is that on my local system I can
>> > source bin/activate and start python and load django but on the Debian
>> > with Apache and mod_wsgi I have just tried the same and cannot load
>> > django. Before trying this method I tried some of the other methods
>> > described in the video "Getting started with Apache/mod_wsgi" at Pycon
>> > Australia and I could successfully load django. I don't know what went
>> > wrong then.
>> >
>> > Any idea?
>> > Thanks
>> >
>> > On Nov 3, 12:27 am, Graham Dumpleton <[email protected]>
>> > wrote:
>> >> Did you disable mod_python from Apache?
>> >>
>> >> Also please start by providing the following:
>> >>
>> >> 1. The actual Apache configuration snippets for mod_wsgi you are using.
>> >> 2. The contents of your WSGI script file.
>> >> 3. Indicate how you created the virtual environment, did you use
>> >> --no-site-packages option to virtualenv.
>> >> 4. The actual error messages from the Apache error logs you are
>> >> getting showing there is a problem.
>> >>
>> >> You can also check you are actually running in daemon mode by
>> >> following:
>> >>
>> >>
>> >> http://code.google.com/p/modwsgi/wiki/CheckingYourInstallation#Embedd...
>> >>
>> >> Anyway, at the moment you are saying it doesn't work but not actually
>> >> saying what is failing. There is going to be no point referring you to
>> >> the same documentation you have likely already read, so lets address
>> >> the specific error or wrong behaviour you are getting instead.
>> >>
>> >> Graham
>> >>
>> >> On 3 November 2011 06:40, karme <[email protected]> wrote:
>> >>
>> >>
>> >>
>> >>
>> >>
>> >>
>> >>
>> >> > Hi,
>> >>
>> >> > I have read the docs and watched the videos but yet cannot make it
>> >> > work.
>> >> > I have tried the various options and at times almost got it working.
>> >>
>> >> > Now I'd like your help.
>> >>
>> >> > - What I have: a standard Debian squeeze with Apache2, python and
>> >> > mod_wsgi installed via apt-get.
>> >> > - What I want: being able to run Django with mod_wsgi in daemon mode
>> >> > using what's inside my project directory only, using virtualenv, I
>> >> > don't even have django installed in the system.
>> >> > - What is working: the daemon mode seems to be working since I set it
>> >> > up to run with my user and I see it like that in top / ps while
>> >> > accessing the virtual host which is running the hello world wsgi
>> >> > program succesfully.
>> >>
>> >> > Now I tried to run Django with different method found in the various
>> >> > docs to no avail. I'm trying again from scratch. Could you please
>> >> > tell
>> >> > me what is the preferred way to achieve the aforementioned goal so I
>> >> > can try again? Or may be tell me if my current setup is wrong? Please
>> >> > provide some code or even just some references to the docs. If more
>> >> > info is needed I can provide it.
>> >> > Any help would be much appreciated. Last time I deployed a Django app
>> >> > was with mod_python and I can't remember having such troubles, is it
>> >> > me or mod_wsgi is a bit more complicated to handle?
>> >> > Thanks.
>> >>
>> >> > --
>> >> > 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
>> >> > athttp://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.
>>
>
> --
> 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