run a exe miss uncompressed.tpk
Excuse me! when I use pyinstaller to package into EXE, and then I run the EXE program and get an error message, can you help me.
Error Info
PermissionError: [Errno 13] Permission denied: 'C:\\Users\\Jack\\AppData\\Local\\Temp\\_MEI54842\\UnityPy\\resources\\uncompressed.tpk'
Here's my packing setup
pyinstaller -D -p D:\Project\Unpack3d\Unpack3d\env\Lib\site-packages --add-binary="D:\Project\Unpack3d\Unpack3d\env\Lib\site-packages\UnityPy\resources\uncompressed.tpk;.\UnityPy\resources\uncompressed.tpk" -F D:\Project\Unpack3d\Unpack3d\Unpack3d.py
The problem is simply related to how UnityPy loads the tpk. Currently it uses os.path, and I guess it's fair to assume that most tools don't check for things like this.
https://setuptools.pypa.io/en/latest/pkg_resources.html should likely work though. I will fix this on Sunday.
Can you check if this branch works for you?
I pulled the branch and tested my code on it, and I tried to package it with pyinstaller, but I still get an error
this is my test code: UnityPyTest.zip
According to PyInstaller wiki, with --add-data and --add-binary you should specify the destination directory instead of its filename.
--add-data SOURCE:DEST Additional data files or directories containing data files to be added to the application. The argument value should be in form of “source:dest_dir”, where source is the path to file (or directory) to be collected, dest_dir is the destination directory relative to the top-level application directory, and both paths are separated by a colon (:). To put a file in the top-level application directory, use . as a dest_dir. This option can be used multiple times.
This should work as intended:
pyinstaller -D -p D:\Project\Unpack3d\Unpack3d\env\Lib\site-packages --add-binary="D:\Project\Unpack3d\Unpack3d\env\Lib\site-packages\UnityPy\resources\uncompressed.tpk;.\UnityPy\resources" -F D:\Project\Unpack3d\Unpack3d\Unpack3d.py
FYI here are some other useful links related to using UnityPy with PyInstaller
- https://github.com/K0lb3/UnityPy/issues/184
- https://github.com/mos9527/sssekai/blob/main/sssekai.spec
According to PyInstaller wiki, with
--add-dataand--add-binaryyou should specify the destination directory instead of its filename.--add-data SOURCE:DEST Additional data files or directories containing data files to be added to the application. The argument value should be in form of “source:dest_dir”, where source is the path to file (or directory) to be collected, dest_dir is the destination directory relative to the top-level application directory, and both paths are separated by a colon (:). To put a file in the top-level application directory, use . as a dest_dir. This option can be used multiple times.
This should work as intended:
pyinstaller -D -p D:\Project\Unpack3d\Unpack3d\env\Lib\site-packages --add-binary="D:\Project\Unpack3d\Unpack3d\env\Lib\site-packages\UnityPy\resources\uncompressed.tpk;.\UnityPy\resources" -F D:\Project\Unpack3d\Unpack3d\Unpack3d.pyFYI here are some other useful links related to using UnityPy with PyInstaller
- Using pyinstaller misses some files from UnityPy #184
- https://github.com/mos9527/sssekai/blob/main/sssekai.spec
Thanks that fixed it for me,It's a great solution,i will close this this issuse