Reputation: 1779
I am writing a little gui application with Tkinter, which requires me to have a path to icon files. I am planning on embedding the file into the exe that I make with py2exe, and then retrieving it from there. The only problem is that I need to know where that file is. Does anyone know a way of getting the currently running exe file/path? Thanks for the help in advance!
Upvotes: 1
Views: 1709
Reputation: 194
A couple of useful links for people coming across this question. The latter provides a nice example -
http://www.py2exe.org/index.cgi/Py2exeEnvironment
http://www.py2exe.org/index.cgi/WhereAmI
Upvotes: 1
Reputation: 1779
Oops! I found out the answer! sys.executable should do the trick. It returns the path and filename of the currently running exe, although I must test to see that it works with py2exe.
Upvotes: 0
Reputation: 4578
_file = os.path.abspath(sys.argv[0])
path = os.path.dirname(_file)
Upvotes: 5