Reputation: 15
My Program works perfectly as long as i run it as a .py file but after converting to exe i get this error
_tkinter.TclError: couldn't open "C:\Users\MYNAME~1\AppData\Local\Temp\_MEI107362\tkfilebrowser\images\file.png": no such file or directory
Why is Trying to open that file here is my code
name = askopenfilename( parent=root, initialdir='/', initialfile='tmp', \
filetypes=[("JPG", "*.jpg"), ("MP3", "*.mp3"), ("TXT", "*.txt")])
I used pyinstaller for converting
Upvotes: 0
Views: 1205
Reputation: 631
tkfilebrowser is using some images that need to be included for your software to work. here is the build command that work on my computer:
pyinstaller --onefile --add-data c:\Users\eric\AppData\Local\Programs\Python\Python38\Lib\site-packages\tkfilebrowser\images;tkfilebrowser\images mytest.py
Just replace c:\Users\eric\AppData\Local\Programs\Python\Python38\Lib\site-package with the path to your own site-package
Upvotes: 1
Reputation: 2675
That is because the files should not be open using the \
. The proper string to open files is the \\
. That comes from the \
is being used to escape characters, which python interpreted it like that.
name = askopenfilename( parent=root, initialdir='\\', initialfile='tmp', \
filetypes=[("JPG", "*.jpg"), ("MP3", "*.mp3"), ("TXT", "*.txt")])
Upvotes: 1