Closed shlomiz89 closed 5 months ago
👋 Hi, just a reminder that if you haven't read the help post yet, give it a read to see if your issue is covered in it and make sure to follow the debugging section.
Also please note, as stated in the README, if your issue is only associated with your application and not auto-py-to-exe itself, please do not create an issue in this repository - instead, comment on the help post, video or create a new discussion.
I see you are referencing "enter.jpg"
in your script - since this is a relative reference, it will resolve relatively to the current working directory, which will most likely not be where the file is actually being stored in the bundle output.
To fix this, you need to wrap file references with resource_path
to correctly turn a relative path into an absolute path which will point to the correct file. For example,
icon.addPixmap(QtGui.QPixmap(resource_path("enter.jpg")), QtGui.QIcon.Normal, QtGui.QIcon.Off)
You can read more about this in the help post under "The one-file Resource Wrapper".
Thank you very much for fast answer
should i write this code into my code?
i mentioned this in the class before setupUi def
def resource_path(relative_path):
import sys, os
try:
# PyInstaller creates a temp folder and stores path in _MEIPASS
base_path = sys._MEIPASS
except Exception:
base_path = os.path.abspath(".")
return os.path.join(base_path, relative_path)
and reference it in
icon.addPixmap(QtGui.QPixmap(resource_path("enter.jpg")), QtGui.QIcon.Normal, QtGui.QIcon.Off)
i receive an error - undefined name "resource_path"
Yes, you need to add that function yourself. Nothing provides it for you and this tool doesn't add anything to your application.
you the besttttt!!!!!!! thank you <3
Are you using the "The one-file Resource Wrapper" snippet that I provided? You haven't said anything about it? I believe those files are there but you're not looking for them in the right place. Simply running the exe and the images not appearing in the GUI is not enough proof to tell me they're not there.
What was your thorough testing?
In the help post I extensively link I state:
Lets do some checking where we actually look at the folder:
Step 6 should prove that your images are coming through. Just because we are bundling a different script doesn't mean that this will change which files are output (aside from Python script).
Originally posted by @brentvollebregt in https://github.com/brentvollebregt/auto-py-to-exe/issues/121#issuecomment-687667654
Hi, i have the same problem. i did the steps you mentioned above, the exe file not showing my images. but the images exist in the directory ("one directory" option) if i run through Spyder it's work good
the python code written as following: