Created a new django project with /tmp$ django startproject testsite
configured apache2 to run the application in /tmp/testsite/testsite/wsgi.py
Inside the wsgi.py there's a simple line import django
(this is everything at the moment, because i'm trying to debug).
I did configure the httpd.conf to run the wsgi file, which (i think) works, because the logs loog like this:
Wed Feb 26 16:55:07 2014] [error] [client 127.0.0.1] mod_wsgi (pid=12621): Target WSGI script '/tmp/testsite/testsite/wsgi.py' cannot be loaded as Python module.
[Wed Feb 26 16:55:07 2014] [error] [client 127.0.0.1] mod_wsgi (pid=12621): Exception occurred processing WSGI script '/tmp/testsite/testsite/wsgi.py'.
[Wed Feb 26 16:55:07 2014] [error] [client 127.0.0.1] Traceback (most recent call last):
[Wed Feb 26 16:55:07 2014] [error] [client 127.0.0.1] File "/tmp/testsite/testsite/wsgi.py", line 26, in <module>
[Wed Feb 26 16:55:07 2014] [error] [client 127.0.0.1] import django
[Wed Feb 26 16:55:07 2014] [error] [client 127.0.0.1] ImportError: No module named django
I then checked if i have the required libraries on the sys.path, with a print - this showed that at the point of running the import
statement, the sys.path was ok (In more detail, i had /...../sistem-packages
in sys.path
Also looked at this link and tried a chmod a+x wsgi.py
, but the same error still appeared.
For reference, here are my files:
httpd.conf
WSGIScriptAlias /vwh /tmp/testsite/testsite/wsgi.py
WSGIPythonPath /tmp/testsite:/home/local/smth/user/ve/tmp1/lib/python2.7/site-packages
<Directory /tmp/testsite/testsite>
<Files wsgi.py>
Order deny,allow
#Require all granted
Allow from all
</Files>
</Directory>
wsgi.py
import os
import sys
from subprocess import call
#print call(["which", "python"]) #also this gives a VERY weird result... prints `0`
import django
Also, tried printing the output of subprocess.call(['which','python']) but that has the weirdest result - returns 0
and i dont' know how to interpret it
[EDIT] I am the virtualenv what was installed at path /home/local/smth/user/ve/tmp1
[EDIT] Yes - i can import django from an interpreter, when the specified path is in the sys.path
, and django.__file__
returns /home/local/smth/user/ve/tmp1/local/lib/python2.7/site-packages/django/__init__.pyc