Pyinstaller --hidden-imports not wirking - python

I'm trying to build an exe file from a python game using PyBox2D and Pyglet.
When I build the exe there occurs an error that a module cannot be imported:
Unable to import the back-end pyglet: module 'gui.backends' has no attribute 'pyglet_framework'
I guess this happens because this file only gets imported indirectly/hidden from another file with __import__()
This is my project hierarchy:
I've tried to add the file to pyinstaller on multiple ways. From the directory /SpaceJam/building I've tried calling:
pyinstaller.exe --onefile "../game/spacejam.py" --hidden-import="gui/framework/backends/pyglet_framework.py"
pyinstaller.exe --onefile "../game/spacejam.py" --hidden-import="../gui/framework/backends/pyglet_framework.py"
pyinstaller.exe --onefile "../game/spacejam.py" --hidden-import="../gui/framework/backends/pyglet_framework"
pyinstaller.exe --onefile "../game/spacejam.py" --hidden-import="../gui/framework/backends/*"
but none of that seemed to change anything in the error message.
I feel like I'm missing something obvious. Does somebody have an idea what I might be doing wrong or why the --hidden-import argument doesn't seem to work?

That argument expects a module name, not a filesystem path. How would you import it?
I'm not totally clear on how your project is set up, but try
--hidden-import gui.backends.pyglet_framework

Related

Pyinstaller compile error on unused library

AssertionError: Failed to determine matplotlib's data directory!
Im not using maptolib anywhere and there is another error assiciated with it
File "C:\Python310\lib\site-packages\matplotlib\colors.py", line 51, in <module>
from PIL import Image
ModuleNotFoundError: No module named 'PIL'
My command
pyinstaller --noconfirm --onefile -w --console --name "Project1" --add-data "C:/Users/user/Desktop/bot/app.py;." --add-data "C:/Users/user/Desktop/bot/czgen.py;." --add-data "C:/Users/user/Desktop/bot/sk.py;." --add-data "C:/Users/user/Desktop/bot/site.py;." --hidden-import "colorama" "C:/Users/user/Desktop/bot/main.py"
Any ideas?
i think one of the modules you used needs matplotlib, so check if everything works. otherwise, i would suggest to clear out the virtual enviroment and downloading everything back. this way the issue will be inside of the code and not in pyinstaller, therefore it'll be easier to debug and find the issue.

App using TKinterModernThemes made with PyInstaller gives the error "invalid command name "set_theme""

I've been trying to make an app using tkinter, TKinterModernThemes, and turn it into an executable with PyInstaller, and I've had no luck. Every time I try to use any kind of module using ttk themes, I run into some sort of error. I decided to settle on using the TKinterModernThemes module. Making an exe using PyInstaller gives me the following error:
File "TKinterModernThemes\__init__.py", line 66, in __init__
_tkinter.TclError: invalid command name "set_theme"
I've tried including both tkinter and TKinterModernThemes as a hidden import in PyInstaller, trying with and without --onefile, and using Nuitka instead (same error). Any help would be wonderful.
I changed manually my path here ThemedTKinterFrame.__init__, at line 64 like this
self.root.tk.call("source", "/home/pi/.local/lib/python3.7/site-packages/TKinterModernThemes/themes/" + theme.lower() + "/" + theme.lower() + ".tcl")
and it works.
pyinstaller --noconsole --onefile --collect-data TKinterModernThemes --collect-data PIL .\FILENAME.py
SAVED MY LIFE!!!
This is now fixed in version 1.9.0 - the issue was the '/../' that I had in the library to move up a directory - the os.path.abspath handles this better.

no module named cv2 pyinstaller

i made a python script(flask) that use html and generate a local host link to open my website i also imported some deep learning models to my project what i want is i want to make an exe file that gives me the output is the local host link so i used this command to make it
pyinstaller --onefile main.py
but when i run my exe file it gives me this error
no module named cv2
i also tried this command
pyinstaller spec_an_API.py --onefile --add-data "templates";"templates" --add-data "static";"static"
but same problem
not that my program has no errors i tried to run it from pycharm and it works well

pyinstaller binary not finding library files

I have a python program I'm converting to a single binary file and then moving to a different platform. When I run the binary it's complaining about a missing library. What's confusing is that it is present. How can I fix this error?
Binary Created:
pyinstaller --hidden-import pyaudio --hidden-import wave --hidden-import Logger --hidden-import json --hidden-import websockets --hidden-import asyncio --onefile Run_SD.py
Running Binary (on different platform):
/lib/libcrypto.so.1.1
/usr/lib/libcrypto.so.1.1
~$ ./Run_SD
[3656] Error loading Python lib '/tmp/_MEIgqfADy/libpython3.7m.so.1.0': dlopen: libcrypt.so.1: cannot open shared object file: No such file or directory
But the library is on the platform:
/lib/libcrypto.so.1.1
/usr/lib/libcrypto.so.1.1
(on the source plaform it's at: /usr/lib/aarch64-linux-gnu/libcrypto.so.1.1 )
I have found a solution .. not sure it's the correct one, but it works.
I copied the missing file into the source directory and then added --add-binary libcrypt.so.1:. to the command line which includes the file into the build and then all works.

pyinstaller: error: the following arguments are required: scriptname

i am trying to make a simple executable file using pyinstaller. by following the steps given in link blow.
[https://datatofish.com/executable-pyinstaller/]
but at step 5 i am getting the error for using command
"pyinstaller --onefile -main"
pyinstaller: error: the following arguments are required: scriptname
my file name is main and it containt only one line
print("hello world")
pyinstaller --onefile -main.py
With pyinstaller it is good practice do rename your file to main.py. Also if you are using GUI, you will probably want -w argument which means without a console.
As the error suggests, you are missing the file name.
try doing it like this.
pyinstaller --onefile main.py
although you are making simple executable file of one line code, it is the most simple case. for this you should try this
"pyinstaller main.py"
the other parameters are used for most complicated code where different libraries are used.
if yet not satisfied just read documentation.

Categories

Resources