Opening a postgres connection in psycopg2 causes python to crash
Asked Answered
F

2

7

I'm getting the following error message when I try to open up a connection to a postgres database. Perhaps it's related to OpenSSL, but I can't understand the error message. Can anyone help?

>>> import psycopg2
>>> conn = psycopg2.connect(host = '', port = , dbname
 = '', user = '', password = '')
Auto configuration failed
12848:error:02001015:system library:fopen:Is a directory:.\crypto\bio\bss_file.c
:169:fopen('D:/Build/OpenSSL/openssl-1.0.1h-vc9-x64/ssl/openssl.cnf','rb')
12848:error:2006D002:BIO routines:BIO_new_file:system lib:.\crypto\bio\bss_file.
c:174:
12848:error:0E078002:configuration file routines:DEF_LOAD:system lib:.\crypto\co
nf\conf_def.c:199:
Fatherhood answered 15/9, 2014 at 18:1 Comment(5)
Are you able to connect to the same Postgres database with other tools, e.g. psql or pgAdmin, without issues?Ollie
I can connect through sql workbench.Fatherhood
It appears that OpenSSL was expecting D:/Build/OpenSSL/openssl-1.0.1h-vc9-x64/ssl/openssl.cnf to be a file, but it's actually a directory. Where did you get your OpenSSL installation from? Have you tried rebuilding/reinstalling it?Ollie
Possible filesystem corruption?Showiness
how did you install psycopg? looks to me like botched install, or lacking dependency librariesAcoustics
A
2

One problem that I can think of is that your installation may not have been linked/built properly to use openssl. If you haven't tried the packages listed in the docs yet, maybe you could give it a try.

When I look at the docs:

Microsoft Windows:

Jason Erickson maintains a packaged Windows port of Psycopg with installation executable. Download. Double click. Done.

So you could try to install it from there. Or you can try the pip-friendly windows-friendly (note: I didn't try it myself) psycopg2-windows package.

Auten answered 6/3, 2015 at 8:19 Comment(0)
D
0

I was seeing a similar issue on MacOSX v14.1.1:

>>> import psycopg2
>>> conn = psycopg2.connect(database="my-db",
...                         host="32.170.20.160",
...                         user="postgres",
...                         password="pass")

Python(16348,0x7ff8454d8b40) malloc: double free for ptr 0x7fcab3811c00
Python(16348,0x7ff8454d8b40) malloc: *** set a breakpoint in malloc_error_break to debug
Abort trap: 6

Installing psycopg2-binary solved it:

python3 -m pip install psycopg2-binary
Drawbar answered 29/2 at 7:11 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.