pyinstaller onefile and Windows XP: access denied on temp folder _MEI

116 views
Skip to first unread message

Giuseppe Modugno

unread,
Jul 3, 2020, 3:07:36 PM7/3/20
to PyInstaller
I thought I have sent this post, but I don't see it in the group, so I write it here again.

I have a single executable created from pyinstaller that works well on many PCs, mainly Windows 10. Now I tried it on Windows XP machine and it failes.

The problem is that the _MEI temporary folder created during startup can't be accessed by the user. I located the folder in Explorer, but it's impossible to enter and delete (Access denied). So pyinstaller script isn't able to extract files to that directory and the process failed with an error.

Do you know how to solve?

bwoodsend

unread,
Jul 6, 2020, 9:04:39 AM7/6/20
to PyInstaller

The short answer:
Use PyInstaller --onefile --runtime-tempdir . myscript.py to have the _MEI folder placed .

The long answer:
You can override where the _MEI folder goes with the --runtime-tmpdir. Quoting the docs:

—runtime-tmpdir PATH
Where to extract libraries and support files in onefile-mode. If this option is given, the bootloader will ignore any temp-folder location defined by the run-time OS. The _MEIxxxxxx- will be created here. Please use this option only if you know what you are doing.

The issue with this is that you have to know at build time the path to a safe run-time location. And as safe usually would imply a user directory and a user directory would likely contain their username and therefore depend on the machine running it this is effectively impossible. Normally you get around this by reading environment variables such as %HOME% but we don’t have that kind of control over the bootloader. The fix for this is to use a path relative to the application (which we’ll assume is in a folder the user has permission for).

Giuseppe Modugno

unread,
Jul 13, 2020, 3:22:26 AM7/13/20
to PyInstaller
I will try --runtime-tmpdir option, anyway I don't think this will solve my problem. I has been able to change the temporary directory without changing original pyinstaller script and command line. I don't remember exactly, but I'm quite sure I changed TEMP or TMP environment variable. So I already tried to point to a directory the user can read, write and execute. The problem is really with _MEI folder. It seems the pyinstaller bootloader make this directory with strange permissions, such that the user itself isn't able to enter, read and delete!

Even with Exporer or command line (DEL), I can't delete the _MEI folder created by pyinstaller. So I don't think the problem is with the temporary directory (the parent of _MEI), the problem is WITH _MEI directory.
Reply all
Reply to author
Forward
0 new messages