Failed psycopg2 connection when started from network drive

0

I have written a Python application that uses psycopg2 to connect to a Postgresql server. When executing the application using Pycharm, with the python-files on a network drive, the connection works without a problem.

I would like to distribute the application for Windows using Pyinstaller. However, when executing the Pyinstaller-built exe-file on the network drive, I get different errors. If I connect to a localhost, I get the following error:

psycopg2.OperationalError: could not translate host name "localhost" to address: Unknown server error

Changing this to a remote host, I get

psycopg2.OperationalError: could not create socket: Invalid argument (0x00002726/10022)

Now, if I copy the dist-folder, which Pyinstaller creates, to a local directory, like C:\temp, it works without any problems.

Is there a specific reason, why I cannot run the application from a network drive? All the involved computers are running Windows (client, server running postgres).

P.S.: Here's a simple example that does not work for me when converted into an exe with Pyinstaller and run from a network drive:

from psycopg2 import connect, extras

if __name__ == "__main__":
    # Basic UI Setup
    dbCon = connect(dbname='datb', user='postgres', host='localhost', password='pw', port='5432')
    cursor = dbCon.cursor(
        cursor_factory=extras.NamedTupleCursor)

    dbCon.close()

Edit: I tried to run the exe from a different network drive and surprisingly, it worked there. The initial network drive is uncooperative. Is this possibly a permission-issue?

python
pyinstaller
psycopg2
asked on Stack Overflow May 16, 2019 by Lgum • edited May 16, 2019 by Lgum

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0