Am 13.02.2021 um 06:34 schrieb Mladen Gogala via Python-list:
On Fri, 12 Feb 2021 18:29:48 +0000, Tony Ogilvie wrote:
I am trying to write a program to open a PostgesSQL 13 database using
psycopg2. All seems to work if I write direct to Python but if I write
the script into IDLE it does not work with the IDLE Shell 3.9.1
reporting an error of no attribute 'connect'.
I have tried many options to try and get this to work.
It looks like your idle is not using the same interpreter that you are
using when writing direct code. Anyway, my advice would be to ditch Idle
and use VSCode. It's fabulous.
That may or may not circumvent the problem but it won't help in clearing
up the cause.
Without any code and without the exact error message we can only guess.
I'm translating "an error of no attribute 'connect'" into
"AttributeError: module 'psycopg2' has no attribute 'connect'". Right?
If yes, that would mean a module with this name was imported, but it
wasn't the right module. Did you perhaps give that same name to some
Python script you wrote yourself? In that case the call to 'connect'
would work if and only if you start your program from a directory that
doesn't contain this script. But of course you should rename it so it
doesn't clash with a module of the standard library.
I think problems with different interpreters would rather result in a
ModuleNotFoundError, wouldn't they?
HTH
Sibylle
--
https://mail.python.org/mailman/listinfo/python-list