Hello,
I have tried to setup apache with hg, trac and web2py running on
Windows XP SP3 but failed. Below is a detailed list of components I
have installed.
hg, trac and web2py work fine standalone (tracd 8000, web2py -
a'<recycle>') but when I try to run them behind Apache with WSGI I see
ImportErrors when importing psycopg2 or mercurial specific modules.
The installation seems to be fine because using PostgreSQL works from
the command line (see below).
I have then setup a 'Hello World' WSGI to prove importing psycopg2 is
the problem. See below for sys.path and Apache log details.
Who knows what is wrong and how to fix?
Regards, Andreas
bal...@gmail.com
-------------
Windows XP SP3
Python 2.6.5
psycopg 2.2.1
trac 0.12
mercurial 1.5.4
web2py 1.79.1
Apache 2.2.15
mod_wsgi 3.0 (win32 ap22py26)
PostgreSQL 8.4.3-1
-------------
-- console --
D:\Home\web\apache\conf>python
Python 2.6.5 (r265:79096, Mar 19 2010, 21:48:26) [MSC v.1500 32 bit
(Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import psycopg2 as pg
>>> db = pg.connect(database='invest', user='invest', password='invest')
>>> db.close()
>>> quit()
-------------
-- Apache configuration --
...
WSGIPythonHome "C:/Apps/Python26"
WSGIPythonPath "C:/Apps/Python26/Lib/site-packages"
WSGIScriptAlias /hw "D:/home/web/apache/cgi-bin/hw.wsgi"
WSGIScriptAlias /hg "D:/home/web/apache/cgi-bin/hgwebdir.wsgi"
WSGIApplicationGroup %{GLOBAL}
...
-------------
-- hgwebdir.wsgi --
from mercurial import demandimport; demandimport.enable()
from mercurial.hgweb.hgwebdir_mod import hgwebdir
application = hgwebdir('D:/home/web/hg/etc/hgweb.config')
-------------
-- Apache error log --
[Sat Jun 19 14:32:35 2010] [error] [client 192.168.178.24] mod_wsgi
(pid=2332): Target WSGI script 'D:/Home/web/apache/cgi-bin/
hgwebdir.wsgi' cannot be loaded as Python module.
[Sat Jun 19 14:32:35 2010] [error] [client 192.168.178.24] mod_wsgi
(pid=2332): Exception occurred processing WSGI script 'D:/Home/web/
apache/cgi-bin/hgwebdir.wsgi'.
[Sat Jun 19 14:32:35 2010] [error] [client 192.168.178.24] Traceback
(most recent call last):
[Sat Jun 19 14:32:35 2010] [error] [client 192.168.178.24] File "D:/
Home/web/apache/cgi-bin/hgwebdir.wsgi", line 51, in <module>
[Sat Jun 19 14:32:35 2010] [error] [client 192.168.178.24]
application = hgwebdir('D:/home/web/hg/etc/hgweb.config')
[Sat Jun 19 14:32:35 2010] [error] [client 192.168.178.24] File "C:\
\Apps\\Python26\\lib\\site-packages\\mercurial\\hgweb\
\hgwebdir_mod.py", line 52, in __init__
[Sat Jun 19 14:32:35 2010] [error] [client 192.168.178.24]
self.refresh()
[Sat Jun 19 14:32:35 2010] [error] [client 192.168.178.24] File "C:\
\Apps\\Python26\\lib\\site-packages\\mercurial\\hgweb\
\hgwebdir_mod.py", line 61, in refresh
[Sat Jun 19 14:32:35 2010] [error] [client 192.168.178.24] u =
ui.ui()
[Sat Jun 19 14:32:35 2010] [error] [client 192.168.178.24] File "C:\
\Apps\\Python26\\lib\\site-packages\\mercurial\\ui.py", line 38, in
__init__
[Sat Jun 19 14:32:35 2010] [error] [client 192.168.178.24] for f
in util.rcpath():
[Sat Jun 19 14:32:35 2010] [error] [client 192.168.178.24] File "C:\
\Apps\\Python26\\lib\\site-packages\\mercurial\\demandimport.py", line
75, in __getattribute__
[Sat Jun 19 14:32:35 2010] [error] [client 192.168.178.24]
self._load()
[Sat Jun 19 14:32:35 2010] [error] [client 192.168.178.24] File "C:\
\Apps\\Python26\\lib\\site-packages\\mercurial\\demandimport.py", line
47, in _load
[Sat Jun 19 14:32:35 2010] [error] [client 192.168.178.24] mod =
_origimport(head, globals, locals)
[Sat Jun 19 14:32:35 2010] [error] [client 192.168.178.24] File "C:\
\Apps\\Python26\\lib\\site-packages\\mercurial\\util.py", line 552, in
<module>
[Sat Jun 19 14:32:35 2010] [error] [client 192.168.178.24] from
windows import *
[Sat Jun 19 14:32:35 2010] [error] [client 192.168.178.24] File "C:\
\Apps\\Python26\\lib\\site-packages\\mercurial\\demandimport.py", line
85, in _demandimport
[Sat Jun 19 14:32:35 2010] [error] [client 192.168.178.24] return
_origimport(name, globals, locals, fromlist)
[Sat Jun 19 14:32:35 2010] [error] [client 192.168.178.24] File "C:\
\Apps\\Python26\\lib\\site-packages\\mercurial\\windows.py", line 21,
in <module>
[Sat Jun 19 14:32:35 2010] [error] [client 192.168.178.24]
posixfile.__doc__ = osutil.posixfile.__doc__
[Sat Jun 19 14:32:35 2010] [error] [client 192.168.178.24] File "C:\
\Apps\\Python26\\lib\\site-packages\\mercurial\\demandimport.py", line
75, in __getattribute__
[Sat Jun 19 14:32:35 2010] [error] [client 192.168.178.24]
self._load()
[Sat Jun 19 14:32:35 2010] [error] [client 192.168.178.24] File "C:\
\Apps\\Python26\\lib\\site-packages\\mercurial\\demandimport.py", line
47, in _load
[Sat Jun 19 14:32:35 2010] [error] [client 192.168.178.24] mod =
_origimport(head, globals, locals)
[Sat Jun 19 14:32:35 2010] [error] [client 192.168.178.24]
ImportError: DLL load failed: The specified module could not be found.
-------------
-- hw.wsgi --
import socket
import sys
# Now for the hello world application.
def application(environ, start_response):
status = '200 OK'
output = '\n'.join(sys.path)
response_headers = [('Content-type', 'text/plain'), ('Content-
Length', str(len(output)))]
start_response(status, response_headers)
return [output]
-------------
-- Output --
C:\Apps\Python26\Lib\site-packages\trac-0.12-py2.6-win32.egg
C:\Apps\Python26\Lib\site-packages\genshi-0.6-py2.6.egg
C:\Apps\Python26\lib\site-packages\trac-0.12-py2.6-win32.egg
C:\Apps\Python26\lib\site-packages\genshi-0.6-py2.6.egg
C:\WINDOWS\system32\python26.zip
C:\Apps\Python26\DLLs
C:\Apps\Python26\lib
C:\Apps\Python26\lib\plat-win
C:\Apps\Python26\lib\lib-tk
C:\Program Files\Apache2.2\bin
C:\Apps\Python26
C:\Apps\Python26\lib\site-packages
C:\Apps\Python26\lib\site-packages\win32
C:\Apps\Python26\lib\site-packages\win32\lib
C:\Apps\Python26\lib\site-packages\Pythonwin
-------------
-- hw.wsgi --
import socket
import sys
import psycopg2
# Now for the hello world application.
def application(environ, start_response):
status = '200 OK'
output = '\n'.join(sys.path)
response_headers = [('Content-type', 'text/plain'), ('Content-
Length', str(len(output)))]
start_response(status, response_headers)
return [output]
-------------
-- Apache error log --
[Sat Jun 19 14:37:06 2010] [error] [client 192.168.178.24] mod_wsgi
(pid=2332): Exception occurred processing WSGI script 'D:/Home/web/
apache/cgi-bin/hw.wsgi'.
[Sat Jun 19 14:37:06 2010] [error] [client 192.168.178.24] Traceback
(most recent call last):
[Sat Jun 19 14:37:06 2010] [error] [client 192.168.178.24] File "D:/
Home/web/apache/cgi-bin/hw.wsgi", line 7, in application
[Sat Jun 19 14:37:06 2010] [error] [client 192.168.178.24] db =
pg.connect(database = 'invest', user='invest', password='invest')
[Sat Jun 19 14:37:06 2010] [error] [client 192.168.178.24] File "C:\
\Apps\\Python26\\lib\\site-packages\\mercurial\\demandimport.py", line
75, in __getattribute__
[Sat Jun 19 14:37:06 2010] [error] [client 192.168.178.24]
self._load()
[Sat Jun 19 14:37:06 2010] [error] [client 192.168.178.24] File "C:\
\Apps\\Python26\\lib\\site-packages\\mercurial\\demandimport.py", line
47, in _load
[Sat Jun 19 14:37:06 2010] [error] [client 192.168.178.24] mod =
_origimport(head, globals, locals)
[Sat Jun 19 14:37:06 2010] [error] [client 192.168.178.24] File "C:\
\Apps\\Python26\\lib\\site-packages\\psycopg2\\__init__.py", line 69,
in <module>
[Sat Jun 19 14:37:06 2010] [error] [client 192.168.178.24] from
_psycopg import BINARY, NUMBER, STRING, DATETIME, ROWID
[Sat Jun 19 14:37:06 2010] [error] [client 192.168.178.24] File "C:\
\Apps\\Python26\\lib\\site-packages\\mercurial\\demandimport.py", line
106, in _demandimport
[Sat Jun 19 14:37:06 2010] [error] [client 192.168.178.24] mod =
_origimport(name, globals, locals)
[Sat Jun 19 14:37:06 2010] [error] [client 192.168.178.24]
ImportError: DLL load failed: The specified module could not be found.
-------------