Skip to content
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

about inspect.py error #6237

Closed
zhanghongyong123456 opened this issue Sep 23, 2021 · 3 comments · Fixed by #6242
Closed

about inspect.py error #6237

zhanghongyong123456 opened this issue Sep 23, 2021 · 3 comments · Fixed by #6242
Labels

Comments

@zhanghongyong123456
Copy link

I have checked many previous answers, but there is still no solution. Looking forward to your reply
A@C_HWQ$1F$Z_(9J1)8B

@zhanghongyong123456 zhanghongyong123456 added the triage Please triage and relabel this issue label Sep 23, 2021
@rokm
Copy link
Member

rokm commented Sep 23, 2021

You need to ensure that source .py files of whatever torch-based library you are using (kornia?) are collected.

Try adding a --collect-all kornia to your PyInstaller command, or use PyInstaller.utils.hooks.collect_data_files('kornia', py_files=True) in your spec file (or a custom hook for kornia).

@rokm
Copy link
Member

rokm commented Sep 23, 2021

And once you have those .py files collected, you will hit a bug where we don't handle packages' __init__.py files correctly in our loader:

if fullname in self.toc:
# Try loading .py file from the filesystem
filename = pyi_os_path.os_path_join(
SYS_PREFIX,
fullname.replace('.', pyi_os_path.os_sep) + '.py')

If you're in a hurry, you can try patching those lines in your local pyinstaller installation, so they read:

        if fullname in self.toc:
            # Try loading .py file from the filesystem
            if self.is_package(fullname):
                fullname += '.__init__'
            filename = pyi_os_path.os_path_join(
                SYS_PREFIX,
                fullname.replace('.', pyi_os_path.os_sep) + '.py')

A simple test program,

# program.py
import kornia
print("Hello")

frozen with pyinstaller --clean --noconfirm --collect-all kornia program.py should work afterwards.

@rokm rokm added bug and removed triage Please triage and relabel this issue labels Sep 23, 2021
@zhanghongyong123456
Copy link
Author

--collect-all kornia

And once you have those .py files collected, you will hit a bug where we don't handle packages' __init__.py files correctly in our loader:

if fullname in self.toc:
# Try loading .py file from the filesystem
filename = pyi_os_path.os_path_join(
SYS_PREFIX,
fullname.replace('.', pyi_os_path.os_sep) + '.py')

If you're in a hurry, you can try patching those lines in your local pyinstaller installation, so they read:

        if fullname in self.toc:
            # Try loading .py file from the filesystem
            if self.is_package(fullname):
                fullname += '.__init__'
            filename = pyi_os_path.os_path_join(
                SYS_PREFIX,
                fullname.replace('.', pyi_os_path.os_sep) + '.py')

A simple test program,

# program.py
import kornia
print("Hello")

frozen with pyinstaller --clean --noconfirm --collect-all kornia program.py should work afterwards.

Yes, he has started to work. Thank you for your reply. Hope you have a wonderful day

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 16, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants