0

Postgrrsql and python

Hi I had postgresql installed on my system. I had python also installed along with pyinstaller and sqlalchemy. I have a simple python file which asks for user password as input and tries to connect to database. It works fine on my machine. I created single file exe from python file and it also works fine. When it did not work is on other machine. This machine has no installation of postgresql or sqlalchemy. How to make this exe work? I had exception set and I was expecting exception shown but it did not respond at all.

22nd Feb 2025, 1:03 PM
Ketan Lalcheta
Ketan Lalcheta - avatar
2 Antworten
+ 1
Ketan Lalcheta here are two options as I'm not exactly sure what you have actually tried so far 🤔 https://sololearn.com/compiler-playground/cSe356Cykf9L/?ref=app
22nd Feb 2025, 4:19 PM
BroFar
BroFar - avatar
0
I'm not sure, but try these: The needed libraries that PostgreSQL libraries depend on might not be available. You have to confirm the required libraries are bundled with the exe file. PostgreSQL uses libraries like libpq.dll. If they are missing, your exe won’t be able to connect to PostgreSQL. You can bundle them with the exe or make sure they are installed on the target mavhine: When creating the exe file, try using the --hidden-import command for PyInstaller to ensure all needed modules are bundled. Just for an example(assuming you import psycopg2 library): pyinstaller --onefile --hidden-import=sqlalchemy --hidden-import=psycopg2 myscript.py If your script uses/depends on other libraries, see if they're available in the system by adding missing things with --add data, like(replace path_to_libpq.dll with the path of the libpq.dll library file): pyinstaller --onefile --add-data "path_to_the_libpq.dll;." myscript.py You should check BroFar code, it looks good.
22nd Feb 2025, 5:01 PM
Afnan Irtesum Chowdhury
Afnan Irtesum Chowdhury - avatar