I made my application with python but I want to convert it to .exe, I can achieve the conversion from .py to exe but not with the image. The image works fine if I run the application in its original format which is .py but when I convert it to .exe it doesn't work. If you have used pyinstaller, can you give me any recommendations, thanks? I am using pyinstaller 3.2 with python 3.4.1 installeddo.
photo = PhotoImage(file="pirate.png")
label = Label(window, image=photo)
label.pack()
The error message.
File "lukcid3.py", line 49, in <module>
File "tkinter\__init__.py", line 3384, in __init__
File "tkinter\__init__.py", line 3340, in __init__
_tkinter.TclError: couldn't open "image.png": no such file or directory
.spec
a = Analysis(['C:\\Users\\Francesc\\Desktop\\PyInstaller-3.2'],
pathex=['C:\\Users\\Francesc\\Desktop\\PyInstaller-3.2\\lukcid3'],
binaries=None,
datas=None,
hiddenimports=[],
hookspath=[],
runtime_hooks=[],
excludes=[],
win_no_prefer_redirects=False,
win_private_assemblies=False,
cipher=block_cipher)
pyz = PYZ(a.pure, a.zipped_data,
cipher=block_cipher)
exe = EXE(pyz,
a.scripts,
exclude_binaries=True,
name='PyInstaller-3',
debug=False,
strip=False,
upx=True,
console=True )
coll = COLLECT(exe,
a.binaries,
a.zipfiles,
a.datas,
strip=False,
upx=True,
name='PyInstaller-3')
Try putting the following line in your
*.spec
:within
Analysis
. The first element of the tuple is the path to your image locally while the second is the internal path where you want the images in your bundle to be stored . It should be something like this:And tell us if it worked for you.
To learn more about how to use a spec file with PyInstaller you can take a look at this link .