I try several approach 1) Ensure C:\Python27 and its sub folder is writable and readable.
2) Re-setup the python + apache + modwsgi environment as following : 1. Download http://www.python.org/ftp/python/2.7/python-2.7.msi 2. Add System Path : C:\Python27\Scripts;C:\Python27;C:\Program Files\PostgreSQL\8.4\bin 3. Download http://pypi.python.org/packages/2.7/s/setuptools/setuptools-0.6c11.win32-py2.7.exe#md5=57e1e64f6b7c7f1d2eddfc9746bbaf20 4. easy_install psycopg2 5. easy_install mako 6. Download http://lawyersdb.com/mirrors/apache//httpd/binaries/win32/httpd-2.2.17-win32-x86-no_ssl.msi 7. Download http://code.google.com/p/modwsgi/downloads/detail?name=mod_wsgi-win32-ap22py27-3.3.so 8. copy mod_wsgi-win32-ap22py27-3.3.so to C:\Program Files\Apache Software Foundation\Apache2.2\modules 9. Add lines at the end of the file C:\Program Files\Apache Software Foundation\Apache2.2\conf\httpd.conf LoadModule wsgi_module modules/mod_wsgi-win32- ap22py27-3.3.so WSGIScriptAlias / "C:/Projects/SandBox/web/" <Directory "C:/Projects/SandBox/web"> AllowOverride None Options None Order deny,allow Allow from all </Directory> Is there anything I had missed out? Is there any other configuration in mod_wsgi I can try out? Thanks! On Nov 18, 6:04 pm, Graham Dumpleton <[email protected]> wrote: > Apache runs as special Windows service, not as you. That special user > may not have permission to read the files you unpacked. Review > ownership and permissions on files. > > With respect to the error message, it said: > > [Thu Nov 18 14:26:51 2010] [error] [client 127.0.0.1] File > "build\\bdist.win32\\egg\\psycopg2\\__init__.py", line 65, in <module> > > Why isn't it an absolute path and instead just 'build'. That is what I > am querying as it doesn't look right. Would expect it to get the > __init__py from the expanded egg in site-packages. > > Graham > > On Thursday, November 18, 2010, yccheok <[email protected]> wrote: > > Here is the output from sys.path > > > 'C:\\\\Python27\\\\lib\\\\site-packages\\\\psycopg2-2.2.2-py2.7- > > win32.egg', > > 'C:\\\\Python27\\\\lib\\\\site-packages\\\\mako-0.3.5-py2.7.egg', > > 'C:\\\\Python27\\\\lib\\\\site-packages\\\\markupsafe-0.11-py2.7- > > win32.egg', > > 'C:\\\\Python27\\\\lib\\\\site-packages\\\\beaker-1.5.4-py2.7.egg', > > 'C:\\\\WINDOWS\\\\system32\\\\python27.zip', > > 'C:\\\\Python27\\\\Lib', > > 'C:\\\\Python27\\\\DLLs', > > 'C:\\\\Python27\\\\Lib\\\\lib-tk', > > 'C:\\\\Program Files\\\\Apache Software Foundation\\\\Apache2.2', > > 'C:\\\\Program Files\\\\Apache Software Foundation\\\\Apache2.2\\\ > > \bin', > > 'C:\\\\Python27', > > 'C:\\\\Python27\\\\lib\\\\site-packages', > > 'C:/Projects/SandBox/web/script' > > > Not. > > > C:\Python27\Lib\site-packages\psycopg2-2.2.2-py2.7- > > win32.egg\psycopg2\tz.py > > > is not a build directory. What I means is that, I use 7-zip to open up > > C:\Python27\Lib\site-packages\psycopg2-2.2.2-py2.7- > > win32.egg archive, I can see there is file C:\Python27\Lib\site- > > packages\psycopg2-2.2.2-py2.7- > > win32.egg\psycopg2\tz.py in the archive > > > From sys.path, it makes sense to me. But, why the error occur? > > > Thanks! > > > On Nov 18, 4:45 pm, Graham Dumpleton <[email protected]> > > wrote: > >> On Thursday, November 18, 2010, yccheok <[email protected]> wrote: > >> > I am using Windows XP, and using Python run time from > >> >http://www.python.org/ftp/python/2.7/python-2.7.msi > > >> > If I am running in standalone application, import psycopg2 doesn't > >> > cause me any trouble. However, when come to mod_wsgi + apache, I will > >> > get the following error > > >> > [Thu Nov 18 14:26:51 2010] [error] [client 127.0.0.1] mod_wsgi > >> > (pid=2832): Target WSGI script 'C:/Projects/SandBox/web/script/ > >> > index.py' cannot be loaded as Python module. > >> > [Thu Nov 18 14:26:51 2010] [error] [client 127.0.0.1] mod_wsgi > >> > (pid=2832): Exception occurred processing WSGI script 'C:/Projects/ > >> > SandBox/web/script/index.py'. > >> > [Thu Nov 18 14:26:51 2010] [error] [client 127.0.0.1] Traceback (most > >> > recent call last): > >> > [Thu Nov 18 14:26:51 2010] [error] [client 127.0.0.1] File "C:/ > >> > Projects/SandBox/web/script/index.py", line 9, in <module> > >> > [Thu Nov 18 14:26:51 2010] [error] [client 127.0.0.1] import > >> > psycopg2 > >> > [Thu Nov 18 14:26:51 2010] [error] [client 127.0.0.1] File "build\ > >> > \bdist.win32\\egg\\psycopg2\\__init__.py", line 65, in <module> > > >> Why is psycopg2 being imported from that build directory. This is a > >> different place than site-packages you are referring to. Something is > >> amiss with Python module search path. > > >> Log the value of sys.path from you WSGI test script and see if you can > >> work out why it is picking up build directory. > > >> Graham, > > >> > [Thu Nov 18 14:26:51 2010] [error] [client 127.0.0.1] from > >> > psycopg2 import tz > >> > [Thu Nov 18 14:26:51 2010] [error] [client 127.0.0.1] ImportError: > >> > cannot import name tz > > >> > Here is the python script. > > >> > import sys, os > >> > sys.path.append(os.path.dirname(__file__)) > > >> > import psycopg2 > > >> > 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) > > >> > return [output] > > >> > and here is the httpd.conf file. > > >> > LoadModule wsgi_module modules/mod_wsgi-win32-ap22py27-3.3.so > >> > WSGIScriptAlias / "C:/Projects/SandBox/web/" > >> > <Directory "C:/Projects/SandBox/web"> > >> > AllowOverride None > >> > Options None > >> > Order deny,allow > >> > Allow from all > >> > </Directory> > > >> > I check the archive C:\Python27\Lib\site-packages\psycopg2-2.2.2-py2.7- > >> > win32.egg\, i found C:\Python27\Lib\site-packages\psycopg2-2.2.2-py2.7- > >> > win32.egg\psycopg2\tz.py within the archive. > > >> > 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 > > 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.
