Thanks for your comments.

Do you remember how you did it? I can make it work correctly when
using the source version of web2py, and I install psycopg under the
python installation (c:\python27).

However, when trying the binary distribution, I have tried extracting
the files from the psycopg version for python 2.5, and putting them:

 a) Inside web2py\site-packages: They work if I start a shell and try
"import psycopg2", "psycopg2.connect(...)", etc. However they are not
detected as an available driver, and trying to connect the DAL to
Postgres fails with "Unable to import driver"
 b) I tried putting the files inside the library.zip file created by
py2exe, but it just didn't work even when importing from the
application shell...

I have managed to get it working using portable python + web2py source
distribution, but I think it would be easier to bundle it with web2py
binary.

Greets.

On Jan 11, 11:55 am, Alan Etkin <spame...@gmail.com> wrote:
> I think i installed one of the listed binary files listed here without
> problems:http://stickpeople.com/projects/python/win-psycopg/
>
> Regards
>
> On 10 ene, 17:14, Álvaro J. Iradier <airad...@gmail.com> wrote:
>
>
>
>
>
>
>
> > Hi,
>
> > I was trying to distribute an application with web2py binary for
> > windows, but I required the PostgreSQL driver. So I copied the
> > psycopg2 files to site-packages in the web2py binary folder.
>
> > If I start a shell from an application, I can import psycopg2 and
> > connect to the database. However, it looks like the DAL does not
> > recognize the psycopg2 driver. I am getting the error:
>
> > Traceback (most recent call last):
> >   File "gluon/restricted.py", line 204, in restricted
> >   File "C:/Users/airadier/Downloads/web2py_win/web2py/applications/
> > init/models/10_db.py", line 13, in <module>
> >   File "gluon/dal.py", line 4749, in __init__
> > RuntimeError: Failure to connect, tried 5 times:
> > Traceback (most recent call last):
> >   File "gluon/dal.py", line 4736, in __init__
> >   File "gluon/dal.py", line 1867, in __init__
> > RuntimeError: Unable to import driver
>
> > My guess is when DAL is being initialized, the site-packages folder is
> > not yet in the sys.path, so the following fails:
>
> >     try:
> >         import psycopg2
> >         from psycopg2.extensions import adapt as psycopg2_adapt
> >         drivers.append('PostgreSQL')
> >     except ImportError:
> >         logger.debug('no psycopg2 driver')
>
> > Is there a reason for this? Is it a bug or a feature?
>
> > Is there other way to acomplish these? And is it allowed to distribute
> > a binary web2py including the PostgreSQL driver?
>
> > Thanks in advance.

Reply via email to