switching to postgres [RuntimeError: No driver of supported ones ('psycopg2',) is available]

62 views
Skip to first unread message
Message has been deleted

Val K

unread,
Jun 16, 2019, 11:15:57 AM6/16/19
to web...@googlegroups.com
What is your platform? How do you start web2py? Do you use virtualenv? This can happen when you have multiple pythons installed or if you use virtualenv.So you can install psycopg2 for one python, but web2py is run by another one.

Val K

unread,
Jun 16, 2019, 11:21:52 AM6/16/19
to web2py-users
Did you restart web2py after installation?

Eliezer (Vlad) Tseytkin

unread,
Jun 16, 2019, 11:54:20 AM6/16/19
to web...@googlegroups.com
On this one I run web2py on Windows. Using web2py from source. No idea what virtualenv is, so presumably not using it. Installed psycopg2 with pip3 specifically, to make sure it goes into the right Python. (I am not too familiar with this, but anything I install with pip goes to Python 2, and pip3 puts everything under Python 3 which I use for web2py). And yes, this is my development computer, so I restart web2py every time. 

On Sun, Jun 16, 2019, 7:21 AM Val K <valq...@gmail.com> wrote:
Did you restart web2py after installation?

--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
You received this message because you are subscribed to a topic in the Google Groups "web2py-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/web2py/UINJvjQAyZk/unsubscribe.
To unsubscribe from this group and all its topics, send an email to web2py+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/web2py/f86e442f-924a-4c97-b773-7865277006c4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Vlad

unread,
Jun 16, 2019, 2:41:22 PM6/16/19
to web2py-users
Okay, I recreated it in a simplest form, to get rid of any extra parameters. Can't make it working neither on windows nor on linux. Here is exactly what's going on: 

on linux: 

the following code
import psycopg2
connection
= psycopg2.connect(database="test_db", user="test", password="xxxxx", host="xxx-994.postgres.pythonanywhere-services.com", port=10994)
executes perfect. a valid connection is received. 

However, when I specify exactly same in the appconfig ( postgres://test:xxxxx?!@xxx-994.postgres.pythonanywhere-services.com:10994/test_db ) it fails with the following error:
psycopg2.OperationalError: FATAL: password authentication failed for user "test"

The user and the password are correct though - besides creating a connection successfully by the code above, I've also verified in postgres itself, to make sure that the user was created successfully and that the permissions were given correctly. So it makes no sense that password authentication fails. 

and here is what I have on windows: 

the code above doesn't even create a valid connection. Here is the error: "OperationalError(could not connect to server: Connection timed out (0x0000274C/10060) Is the server running on host "xxx-994.postgres.pythonanywhere-services.com" (10.0.0.70) and accepting TCP/IP connections on port 10994? )"

and when I specify the db in appconfig, it's a similar error (just coming from web2py wrapper, I guess): "psycopg2.OperationalError: could not connect to server: Connection timed out (0x0000274C/10060) Is the server running on host "xxx-994.postgres.pythonanywhere-services.com" (10.0.0.70) and accepting TCP/IP connections on port 10994?"

So psycopg2 at this point is present and found by Python (not even sure what was the problem before, when it couldn't be found on windows), but on windows connection fails, while on linux password authentication fails.

Greatly appreciate any ideas. 



On Sunday, June 16, 2019 at 7:54:20 AM UTC-4, Vlad wrote:
On this one I run web2py on Windows. Using web2py from source. No idea what virtualenv is, so presumably not using it. Installed psycopg2 with pip3 specifically, to make sure it goes into the right Python. (I am not too familiar with this, but anything I install with pip goes to Python 2, and pip3 puts everything under Python 3 which I use for web2py). And yes, this is my development computer, so I restart web2py every time. 

On Sun, Jun 16, 2019, 7:21 AM Val K <valq...@gmail.com> wrote:
Did you restart web2py after installation?

--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
You received this message because you are subscribed to a topic in the Google Groups "web2py-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/web2py/UINJvjQAyZk/unsubscribe.
To unsubscribe from this group and all its topics, send an email to web2py+unsubscribe@googlegroups.com.

Vlad

unread,
Jun 16, 2019, 7:49:27 PM6/16/19
to web2py-users
I've got 50% of the answer. They require ssh tunnel to be used and don't allow any direct connection. I understand that there is security reason for that, yet I am at loss on how to handle this better. 

Keeping ssh tunnel alive is problematic (for development it's fine, but for production...) 

So the only feasible solution for production environment to have "internal" db, i.e. hosted in the same very web2py server environment locally to avoid using tunnels. I mean, I am talking about cloud postgres providers - I don't think it's practical for me to become a postgres expert quickly and take care of its hosting by myself to allow a direct connection. 

Is this correct? 

But regardless of tunnels, I have a problem with PythonAnywhere thing, because there I use PA postgress and no tunnel required in such a configuration. So, while this opens a valid connection: 

import psycopg2
connection
= psycopg2.connect(database="test_db", user="test", password="xxxxx", host="xxx-994.postgres.pythonanywhere-services.com", port=10994)

web2py reports a connection error (i.e. when I specify db in appconfig instead of opening a connection manually as above):

psycopg2.OperationalError: FATAL: password authentication failed for user "test"

So exact same settings fail when in web2py ( postgres://test:xxxxx?!@xxx-994.postgres.pythonanywhere-services.com:10994/test_db )

Greatly appreciate some pointers to the db direction. I am at loss on how to handle this gracefully. SQLite has served perfect up until now, when I have to get to a real db... 

Val K

unread,
Jun 16, 2019, 10:39:13 PM6/16/19
to web2py-users
If you can connect from python It should work from web2py as well

'?!' - is this typo? ( in  postgres://test:xxxxx?!@...),  I mean that password goes from : to @  


To unsubscribe from this group and all its topics, send an email to web...@googlegroups.com.

Vlad

unread,
Jun 17, 2019, 2:00:08 AM6/17/19
to web2py-users
Yes, it was a typo. There were quite a few things that went wrong and I missed this one even after looking at it dozens of times, checking each character...

It's perfect now.

Thank you very much

Reply all
Reply to author
Forward
0 new messages