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?


for pyinstaller I am using this line:

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.

Leave a Reply