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

Trying to pack into a EXE #459

Open
sufianadnan opened this issue Mar 12, 2023 · 1 comment
Open

Trying to pack into a EXE #459

sufianadnan opened this issue Mar 12, 2023 · 1 comment

Comments

@sufianadnan
Copy link

File "discum\importmanager.py", line 10, in func
KeyError: 'SuperProperties'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "1.py", line 7, in
File "discum\discum.py", line 89, in init
File "discum\discum.py", line 222, in getSuperProperties
File "discum\importmanager.py", line 12, in func
ModuleNotFoundError: No module named 'discum.start'
[18524] Failed to execute script '1' due to unhandled exception!

pyinstaller --noconfirm --onefile --console --add-data "/Images;Images/" "/1.py"

note the path is correct above

@reconSuave
Copy link

reconSuave commented Apr 4, 2023

Pyinstaller isn't looking in the right place for dependencies, some things you can try:

tell pyinstaller where discum is:

 --paths "/full_path_to/venv/lib/python3.x/site-packages/discum/"

tell pyinstaller where discum.start is:

 --paths "/full_path_to/venv/lib/python3.x/site-packages/discum/start"

tell pyinstaller to collect everything under discum package:

--collect-all "discum"

tell pyinstaller to collect discum.start as a hidden import:

--hidden-import "discum.start"

if those don't solve it, there are some more exotic options like adding a runtime-hook that imports the discum package and initializes your script, or making discum into a shared library and adding it to the compiled exe and modifying your script to call the functions from the library.

But probably one of the above options, or some combination of those options, will fix it. In all likelihood you just need to tell pyinstaller where to look for dependencies. Also make sure you're running pyinstaller from the same virtual environment where discum is installed. And also on that note, sometimes it can help to make a fresh virtual environment and install the dependencies for your script in the fresh virtual environment, and then install and run pyinstaller in the same environent after dependencies are installed.

Pyinstaller can be finicky sometimes and there are multiple ways you can accomplish the same thing which is kind of annoying and unpythonic but with some experimentation you can usually find a way that works for your situation. Also you might want to consider using the auto-py-to-exe package to initialize pyinstaller, it has some advantages like being able to see all the different options for collecting dependencies so you can try them all systematically in a more organized way, and it gives you verbose output by default. In general it just makes troubleshooting easier.

Hope this helps.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants