Your libpq, which is used by psycopg2 expects Postgres socket to be in /var/run/postgresql/
but when you install Postgres from source it is by default it in /tmp/
.
Check if there is a file /tmp/.s.PGSQL.5432
instead of /var/run/postgresql/.s.PGSQL.5432
. Try:
conn=psycopg2.connect(
database="mydb",
user="postgres",
host="/tmp/",
password="123"
)
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…