Open NetinhoDaCosta opened 3 years ago
Hi, as noted in that bug report this have nothing to do with qtmodern so we are not able to fix it. What happens is that pyinstaller does not know about the files that qtmodern uses without you explicitly telling pyinstaller about them, as far as I know there is no way for us to add something in qtmodern to fix it for everyone.
That said let's see if we can help you with your issue.
That part with the "import importlib etc... " Do you add that in the .spec file? Looks like python code
Yes, it is python code. Which is what the .spec
file is (if they haven't recently changed that).
Both of the code block should be pretty much copy and paste into the given locations. The only thing you need to make sure is that the added_file
is added to your datas
in your Analysis
.
I'm also not sure why it looks for that file in the Temp directory? because of MEIPASS?
I am not sure but I think pyinstaller unpack your resources to be able to use them
Would it be possible to add these files using pyinstaller commands? like '--paths' or '--add--data' or '--resource' or '--additional-hooks-dir' for example?
Should be possible, this answer on stack overflow goes through how to add data with the --add-data
argument. You will of course also have to find the absolute paths to the files in qtmoderns resource
folder.
If you have a link to your project I can take a look if you are having problems still.
Hi, as noted in that bug report this have nothing to do with qtmodern so we are not able to fix it. What happens is that pyinstaller does not know about the files that qtmodern uses without you explicitly telling pyinstaller about them, as far as I know there is no way for us to add something in qtmodern to fix it for everyone.
Actually, you can provide a hook in your package to handle this.
the hook-qtmodern.py
file is as simple as that:
from PyInstaller.utils.hooks import collect_data_files
datas = collect_data_files("qtmodern", includes=["**/*.qss"])
And there's no need to check at runtime for the resources position as the previous workaround.
An alternative would be to add the hook to pyinstaller-hooks-contrib.
@NetinhoDaCosta in the meantime, you can create the hook-qtmodern.py
with the code above and either use the --additional-hooks-dir
CLI option or the Analysis
hookdirs
parameter to add the hook folder path.
Awsome find @sanzoghenzo Would you mind creating a PR for qtmodern over there?
Sure! I'm on it.
I opened an issue because I don't know how to handle the optional qt wrappers dependencies and make the test pass. I'll send a PR as soon as I got an anwser.
Simpler than I thought, we pick PyQt5 and run the test with it.
PR merged, too bad that they released a new version just yesterday... Let's wait the next one!
In this post: https://github.com/gmarull/qtmodern/issues/34#issuecomment-564061097 That part with the "import importlib etc... " Do you add that in the .spec file? Looks like python code
I did add the bottom part/code-block in the main python code of my application. Only attempting to figure out how to use that top part. (adding it in either the spec file, or my main python file, still keeps the same error when opening the .exe file) That error is:
Traceback (most recent call last): File "my_filename.py", line 262, in (this number differs depending on my app/code) File "qtmodern\styles.py", line 70, in dark File "qtmodern\styles.py", line 23, in _apply_base_theme FileNotFoundError: [Errno 2] No such file or directory: " 'C:\sers\MyName\AppData\Local\Temp_MEI166802\qtmodern\resources/styles.qss' [36020] failed to execute script my_filename
I have been encountering this problem for quite some time now. This is a good looking style, would love to be able to use it, and get it working. I have the following questions:
I'm also not sure why it looks for that file in the Temp directory? because of MEIPASS? Would it be possible to add these files using pyinstaller commands? like '--paths' or '--add--data' or '--resource' or '--additional-hooks-dir' for example?
Any help to get this working would be hugely appreciated.