Home > Software design >  Getting folder path to script errors after compiling with pyinstaller
Getting folder path to script errors after compiling with pyinstaller

Time:06-13

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:

pyinstaller "Filename" --onefile

CodePudding user response:

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.

  • Related