PyInstaller Failed to execute script while converting from .py to .exe - python

I've been trying to convert a .py file to .exe which has some dependencies (.mp3 and .png files) that i've included while converting from .py to .exe with PyInstaller. The application runs completely fine on PyCharm and cmd venv,when activated. However when i try to run the .exe file i have this error: "Failed to execute script". I've tried everything on the internet but nothing seems to work

Apparently -w was causing a problem so i replaced it with -c and everything seems to be working normally now.

Related

Error while generating executable files using py2exe (python)

I am trying to create an executable file which is using module python-docx.
The executable files is created but this error occurs when I run the executable file.
[Errno 2] No such file or directory: 'D:\Pycharm Projects\pydocx\dist\library.zip\docx\parts\..\templates\default-footer.xml'
The normal .py file which I am trying to convert into a .exe works perfectly fine.
Can anyone suggest how should I resolve this
Switched to pyinstaller and everything worked flawlessly.

Nuitka can't open the .py file for compiling it

[So I have previously used nuitka to create standalone executables for my python scripts and had no issue until this time I tried once again]
I am trying to use nuitka to create a .exe file for my .py script however, it throws the following error:
Nuitka:INFO: Starting Python compilation.
__main__.py: can't open file 'MyPythonProgram.py'.
I have given the following command in the command prompt (run as administrator and in the correct directory):
nuitka --mingw --follow-imports MyPythonProgram.py
I have also tried using --onefile --windows-onefile-tempdir and standalone however the result was the same.
I am using python 3.9.4 and nuitka 0.6.14.4. (Same as last time when it actually worked without throwing any errors)
So let me know, what went wrong with my attempt and how to fix it...
Thanks in advance!

How to create a .exe file from a .py file

I had built a simple program with minimalistic code
Code
and converted it into a .exe file using command prompt after which it refused to boot after I opened the .exe file in Visual Studio after which it prompted this
and allowed it to fix some errors then I saw some changes in the program, But then when I tried to open it, This showed up
and so is there a way to make the program boot and run and do I need additional code to make the program run?
Easy-peasy solution.
Do pip install pyinstaller and then from run pyinstaller --onefile filename.py

Pyinstaller: OSError: Cannot load AutoItX from path

So I have a program and whenever I start it from the command line it works totally fine. What I need now is an Executable and therefor I tried to do it with pyinstaller, which analyzes normally automatically which modules have been imported and it works fine with all of the modules except for autoit. The way I import it looks like that:
import autoit
So I tried to make an executable by following command:
pyinstaller --onefile ./rocketupload.py
Which gave me this Error (Excuse me, that I have to make a screenshot, but the window was open for a second and closed immediately afterwards, so I was not able to copy and paste it here):
I was able to create a functioning exe by copying the autoit dll to the path mentioned in the Error, but that is just a temporary solution, since I want the executable to be running not only on my PC.
I've also tried this one without succes:
pyinstaller --hidden-import=autoit --onefile --paths c:\users\semjo\appdata\local\programs\python\python37\lib\site-packages\autoit\lib .\rocketupload.py
So the problem here is that the autoit module does not get copied from pyinstaller so It cannot run the executable as inteded. But I dont know how to solve it, so that the exe can run as intended. Hope you can help me here, tried to find a solution for hours now...
I had also encountered the same problem and i solved it by implementing the follows:-
Re-installed the pyinstaller module using the latest installer available in github i.e. pip install https://github.com/pyinstaller/pyinstaller/archive/develop.zip
Re-created the executable package by running the command i.e. pyinstaller --hidden-import=selenium --hidden-import=autoit your [python_file.py]
Copied the installed module i.e. autoit's folder from my PC's directory (C:\Users\\AppData\Local\Programs\Python\Python37\Lib\site-packages) and pasted it inside the [python_file] folder in dist folder which was generated by pyinstaller.
To test the solution, i re-run the generated .exe file in command prompt. Hope this help.
hiddenimports = [ "autoit.init", "autoit.autoit", "autoit.control",
"autoit.process", "autoit.win" ]
datas = [
[
"C:\\Python27\\lib\\site-packages\\autoit\\lib\\AutoItX3_x64.dll",
"autoit\\lib"
]
]
https://raveendran.wordpress.com/2012/06/15/how-to-installregister-autoitx3-dll/
Do this two process your issue will resolve. It resolved me.

Pyinstaller- python exe stopped working: "Cannot open self"

I have been using Pyinstaller to convert python scripts into executables. It has worked for me just fine in the past. However now when I try to run the executables (both old ones and new ones) I get the error "Cannot open self _____ or archive _____", where the first blank is the path of the executable and the second is the path of an archive that does not exist, ending in ".pkg". I did change the path of the source code, but that should not be preventing new executables I made after the switch from working, and isn't the point of compiling a .py into a .exe mobility?
I am on windows 7, using the cmd window to run the executables (which I'll repeat has worked in the past.) I'm using Python 3.5, and the commmand with which I am building executables is
pyinstaller.py --onefile --clean programName.py
The same happened to me when I:
kept the executable opened on a Windows virtual machine;
in the same time I began to rebuild the executable with Pyinstaller;
then I rerun the executable and got the same message
Once I closed the application and then ran Pyinstaller, the problem dissapered.

Categories