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.
Related
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.
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
I have a python file I am converting to exe via Pyinstaller. The coversion runs fine with no error, however when I run the exe file I get error in line 13 of the python file (line is import librosa). Then I get a bunch of files and then a
FileNotFoundError: No file or directory: 'C:\\Users\\johnny\\Appdata\\Local\\Temp\\_MEI70722\\librosa\\util\\example_data\\registry.txt'.
Also the python file itself runs fine.
Any help would be appreciated
PyInstaller tries to find all the dependencies, however this file is not imported but loaded so it misses it. You can simply force it to add it:
--add-data [path to your python]/Lib/site-packages/librosa/util/example_data;librosa/util/example_data
With The full command be like :
pyinstaller --onefile [YourScript].py --add-data [path to your python]/Lib/site-packages/librosa/util/example_data/registry.txt;librosa/util/example_data
You'll need to specify the data files as PyInstaller hooks.
Create a folder "extra-hooks", and in it a file "hook-librosa.py"
paste these 2 lines in "extra-hooks/hook-librosa.py":
from PyInstaller.utils.hooks import collect_data_files
datas = collect_data_files('librosa')
Then tell PyInstaller where to locate this file with adding 1 of the following to your PyInstaller command:
--additional-hooks=extra-hooks
--additional-hooks-dir "[PATH_TO_YOUR_PROJECT]/axtra-hooks"
The 2nd one worked for me, and I was using auto-py-to-exe, built on PyInstaller.
I guess the file doesn't exist. Open a file manager and copy the directory.
In the PyInstaller, you should type in the python file's name and then --onefile. It makes an .EXE file (if you are on windows) with all the imported files within. You can learn more here: https://pyinstaller.readthedocs.io/en/stable/usage.html
I have been able to freeze a Python/PySide2 script with fbs on macOS, and the app seems to work.
However, I got some errors from the freeze process stating:
Can not find path ./libshiboken2.abi3.5.13.dylib.
Does anyone know how to fix that?
Try to use the --runtime-tmpdir because while running the generated exe file it needs this file libshiboken2.abi3.5.13.dylib and unable hook that file.
Solution: use --add-data & --runtime-tmpdir to pyinstaller command line.
pyinstaller -F --add-data "path/libshiboken2.abi3.5.13.dylib":"**PATH"
--runtime-tmpdir temp_dir_name your_program.py
here PATH = the directory name of that file looking for.-F = one file
after trying to build a standalone by entering
python pyinstaller.py -F myscript.py
in the pyinstaller directory i get an error:
error: Requires at least one scriptname file or exactly one .specfile
I have the script in the same directory as the pyinstaller. What might be causing the error?
EDIT: To answer the comments: I run the command from the same directory as pyinstaller. I can access both files.
Try adding -m after python.
Also, from what I have seen, and tried, "pyinstaller.py" doesn't work, but after removing the ".py" it works
So, perhaps you can try the following:
python -m PyInstaller -F myscript.py
Note: 'PyInstaller' in this case is case sensitive, it doesn't work if you just use 'pyinstaller'
'pyinstaller' does work however in the following case: pyinstaller -F myscript.py