Python application to send mails fails to execute after packing with pyinstaller

35 views Asked by At

I wrote a python program which is used to ping machines and collected the machines' information and send these information as mail to the users. When I run my python program in Pycharm, it works fine, but when I use pyinstaller to pack this program as an exe , the method which is used for sending mails fails and I can't receive the mail sent by my program but other methods run successfully. This makes me feel confused and I need help to resolve this. (https://i.stack.imgur.com/rKULE.jpg)](https://i.stack.imgur.com/E7Zex.jpg)](https://i.stack.imgur.com/24W7z.jpg) enter image description here

1

There are 1 answers

0
Abhijith On

It seems you are using a file 'sqlconfig.txt' for storing your credentials. When you run the application from Pycharm, it will work as the file is present in the same directory as the code. When packaging with pyinstaller, you need to mention that this file needs to be copied to the same directory as your .exe file. For that, use:

pyinstaller --onedir --w add-data= 'sqlconfig.txt';'.' myscript.py

replace myscript with the name of your script.