UnityPy icon indicating copy to clipboard operation
UnityPy copied to clipboard

run a exe miss uncompressed.tpk

Open EmilyEdna opened this issue 1 year ago • 2 comments

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

EmilyEdna avatar Aug 25 '24 04:08 EmilyEdna

屏幕截图 2024-08-25 123230

EmilyEdna avatar Aug 25 '24 04:08 EmilyEdna

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.

K0lb3 avatar Aug 30 '24 22:08 K0lb3

Can you check if this branch works for you?

K0lb3 avatar Sep 01 '24 18:09 K0lb3

I pulled the branch and tested my code on it, and I tried to package it with pyinstaller, but I still get an error 屏幕截图 2024-09-02 114435

this is my test code: UnityPyTest.zip

EmilyEdna avatar Sep 02 '24 03:09 EmilyEdna

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

mos9527 avatar Sep 03 '24 05:09 mos9527

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

Thanks that fixed it for me,It's a great solution,i will close this this issuse

EmilyEdna avatar Sep 03 '24 12:09 EmilyEdna