Pyinstaller exe single file executable on different computer - python

I am trying to make a gui to control a spectrum analyzer. The code works when running from the IDE. I generate an .exe unsing pyinstaller with the code.pyinstaller.exe --onefile --windowed --icon=spec.ico spectrum_analyzer_gui.py The .exe works great on the computer that generated it.
I tried to run the .exe on a different computer but got an error 'Failed to execute script spectrum_analyzer_gui'
I copied the icon to the same location.
What else do I need to do so the application runs on a different machine?
I have attached a like to a .zip in dropbox with the source code and build.
https://www.dropbox.com/s/87uqynllnlv72c4/Spectrum%20Analyzer%20Gui.zip?dl=0

Try adding a --hidden-import=tkinter to your exe generation.

Related

pyinstaller .exe file doesn't work on another computer

I have used pyinstaller to compile the py file into exe, on my computer it is working well
but when i am trying to download it on another computer it's always giving me error,
FileNotFound: no such file or directory when i compiled the py file i added the python39.dll.
here is the command i used:
pyinstaller --noconfirm --onefile --console --add-binary "C:/Users/Usern/Desktop/dist/python39.dll;." "C:/Users/Usern/Desktop/dist/m.py"
I am trying to create a file with this command:
f1 = open("C:\\Users\\Usern\\AppData\\Local\\Mine\\x.exe", "wb").write(x_req)
again in my computer that .exe file works well as should be but in another computer it does not work.
The program is trying to pull in a file that isnt on the computer. I had the same problem when my program used an image, it had to be in the same directory.

pyinstaller python file + exe in only one exe

py file in which I am executing a .exe file created in C++ (is inside a "data" folder)
Python Code:
os.system("data\\time.exe")
When I use the pyinstaller with the --onefile attribute I can't find a way for my program to compile the .py file + the "data" with another .exe inside.
Does anyone know how to convert my entire program into a single .exe? in which I can run my python program and also my .exe from C++ inside?
(I have tried to test with the .spec and with the --add-data attribute but I can't find a way that is compatible with what I want to do)
I look forward to your response,
Thanks you very much <3
There is a program called auto-py-to-exe which creates an exe out of your program without requiring you to create a setup file. The interface is great and allows you to easily create and exe without creating a setup.py. This also allows you to package your app as a single exe, without any other files. Below is a screenshot:
You can install the program by typing into the command line:
python -m pip install auto-py-to-exe
You can run it by typing in:
auto-py-to-exe
To see more about auto-py-to-exe, please visit the PyPI page at https://pypi.org/project/auto-py-to-exe/.

Failed to execute python script built using PyInstaller (ModuleNotFoundError)

I am trying to turn a .py file into .exe so that it's runnable on other computers without python. I followed this tutorial, installed pyinstaller then ran the command pyinstaller --onefile IRV.py without the -w since my program runs in the console. It successfully built the .exe file but when I run it it immediately closes even though the program itself asks for input at the beginning. It uses a bunch of .txt and .xslx files from the folder of the .py file so I dragged the .exe out of the dist folder but it still gives the same error. I managed to make a quick print screen before it closes and it gives me this error: https://imgur.com/a/w7TVjaN
The script doesn't even work if I double click the .py file. However it runs perfectly fine if I open up the .py file in an IDE like Spyder. When I run the .exe file it opens up the cmd for a few seconds with nothing written on it and then quickly writes that error I managed to screenshot and then closes. If I double click the .py though it instantly closes without the wait or the error message.
Pyinstaller didn't find the libraries or modules you imported. In the build folder that was deleted in the tutorial, there's a text document that shows warnings for libraries that aren't found by the pyinstaller. You may need to check that.
This Q&A mentioned a problem that is related to your Question: No module error when running python script from command prompt

Pick up directory with pyinstaller

I have made a small programm with Python 3 and Qt-Designer using Pyqt5.
the programm should open a pdf file which is located on a directory on my pc and another exe file, which is also on my pc.
I'm using in the code:
os.startfile("D:\Python_files\MA\Programm\K_file\dist\K_D\K_D.exe")
os.startfile("D:\Python_files\MA\Programm\Help.pdf")
then I used pyinstaller to make it standalone app. The problem is that pyinstaller does not pick up those two file (pdf and exe). So when somebodyelse download the app on thier pc, it wont work because the pdf and the exe are missing.
How to fix this?
I'm using this command in pyinstaller
pyinstaller --onefile --icon="if_icon_64682.ico" --clean ProgV_1_6_Final.py

pyinstaller compiled .exe does nothing

Wrote a game and compiled it with pyinstaller. An EXE file was created but when I go to run it, it thinks for 3-4 seconds and then it returns to command prompt.
Clicking from the folder in Windows does nothing.
No errors, nothing! Do I need something in my code to allow this to run? The only imports are tkinter and random.
Edit 1: tested a "hello world" script to see if there were issues with pyinstaller, it ran fine.
I understand that the post is older, but it may be useful for other member who may come across the similar problem.
I had created a script using Jupiter notebook and it creates ipynb file.
When I create an exe file using pyinstaller, the exe was doing nothing.
I resolved it by first converting ipynb file to py file using below command:
pyinstaller my_script.py
It will create the py file under same location.
Now, execute below command to create exe file:
pyinstaller my_script.py
It will create exe file under dist folder.
And it works.

Categories

Resources