Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Getting folder path to script errors after compiling with pyinstaller

I am working on a small gui using Tkinter when I set the path to the icon in the script it works fine but when I run it as a exe file it says it cant be found and the path it displays is AppData\Local\Temp. What am I doing wrong?

root.iconbitmap(os.path.dirname(os.path.realpath(__file__))+"\\Icon.ico")

for pyinstaller I am using this line:

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

pyinstaller "Filename" --onefile

>Solution :

I have ran into this problem before. Don’t use os.path.dirname(os.path.realpath(__file__)) to get the path the file is currently running in, but rather use sys.argv[0].
See this answer for further explanation.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading