New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
--onefile does not work properly #5615
Comments
Can you please fill out the issue template. |
Uf... there's definitely something fishy going on in bootloader when CArchive contains long names... |
On Windows, `pyi_path_fopen()` erroneously uses `MAX_PATH` (260) instead of `PATH_MAX` (4096) to convert the filename to wide characters, which causes `MultiByteToWideChar()` call in `pyi_win32_utils_from_utf8()` to fail with ``` MultiByteToWideChar: The data area passed to a system call is too small. ``` when we try to open a file with a long filename (> 260). Due to lack of error checking, the resulting `wfilename` array ends up with random content, and the `_wfopen()` call either fails (in read-only mode) or creates a randomly-named file (in write mode). Fixes pyinstaller#5615.
Maybe it is because of the additional files that I am loading? I tested a MWE and it lead to the same error when using --onefile: MWE: import os
from google_drive_downloader import GoogleDriveDownloader as gdd
from pathlib import Path
from tensorflow import keras
f_path = 'data/face_model.h5'
if not Path(f_path).is_file():
gdd.download_file_from_google_drive(file_id='xxx', dest_path=f_path)
my_model = keras.models.load_model(f_path) |
I can trigger the
message if full path length of the file to be extracted exceeds 260 characters. In your original post, the length of
is 212 characters; but you also need to add the temporary extraction path for onefile (e.g., `C:\Users<username>\AppData\Local\Temp_MEIXXXXX˙). So if your username is a bit longer (more than 10 characters in this case), you'll hit the issue. |
import os
from google_drive_downloader import GoogleDriveDownloader as gdd
from pathlib import Path
from tensorflow import keras
f_path = 'data/face_model.h5'
if not Path(f_path).is_file():
gdd.download_file_from_google_drive(file_id='xxx', dest_path=f_path)
my_model = keras.models.load_model(f_path) What exactly is the error message with this MWE? Because downloading a file should not trigger the filename-length issue. Unless |
The error message is the same:
Moreover it happens as soon as I am importing keras as follows: from tensorflow import keras Another interesting thing that I observed, was as soon as I imported tensorflow (v. 2.4.1 in conda) I was not able to use pyinstaller on the .py script due to maximum recursion depth. So i needed to increase the depth in the .spec file and rerun the script which took significant longer to build the exe file (almost 20 minutes). |
Hmmm... alright, so the actual problem here seems to be that importing |
That's our bet. But now the question arises how we can fix this tensorflow thing when using |
You can just add |
Unfortunately still the same output. What I could observe is that it takes some time during the conversion process at this step:
|
It should be |
Okay the conversion is now faster but the same error message appears. I am using keras 2.4.3 and tensorflow 2.4.1. Maybe this message helps you identifying the problem:
|
If the exact same error message appears, that means that |
On Windows, `pyi_path_fopen()` erroneously uses `MAX_PATH` (260) instead of `PATH_MAX` (4096) to convert the filename to wide characters, which causes `MultiByteToWideChar()` call in `pyi_win32_utils_from_utf8()` to fail with ``` MultiByteToWideChar: The data area passed to a system call is too small. ``` when we try to open a file with a long filename (> 260). Due to lack of error checking, the resulting `wfilename` array ends up with random content, and the `_wfopen()` call either fails (in read-only mode) or creates a randomly-named file (in write mode). Fixes pyinstaller#5615.
Do you mean the log file in build folder, named |
No, I meant the output you get on console... (also, next time please attach the log as file attachment instead, as pasting it makes it difficult to navigate the issue). |
But anyway, our Windows CI just errored out while testing #5617; the long-filename test that was added is causing the same Can you try enabling long file paths on your system? (i.e., run That might already take care of the issue (the offending file will be created with garbage filename, but it will go unnoticed if it is actually not used anywhere). To fix the issue fully, try installing the following PyInstaller branch, which is the same as #5617 but with rebuilt bootloader:
and then rebuild your program. |
I tried the new branch and the error message now changes to: MWE: import os
from google_drive_downloader import GoogleDriveDownloader as gdd
from pathlib import Path
from tensorflow import keras
print(os.listdir())
So basically it seems to solve the error somehow. But it still takes a relatively long time to execute the file (about 1-2 minutes). |
OK, so that long-filename issue is taken care of.
I've seen this one pop up in issue reports every now and then, but I haven't gotten around investigating it, yet. I suspect it's related to
This is quite normal as well, as you need to collect CUDA DLLs manually, if you want to use them. (Or if you don't have a NVIDIA GPU and their drivers installed).
Since it's a |
Okay, let's summarise what we have so far. We know that if we import tensorflow 2.4.x and then use |
When I run my script normally it works and it also works when I apply the full mode in the pyinstaller (i.e. when all files in the subfolder
dist
are unpacked). However, the .exe file no longer works when I apply the--onefile
mode. The following error message then appears:This is somehow strange since the executable file works when it is placed in dist beside the other packages etc. But as soon as I use
--onefile
to bundle them into one big file it gives this error message.The text was updated successfully, but these errors were encountered: