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

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.

Related

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!

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

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.

I can't convert pygame to exe

I made an app for my friends but I can't make executable file. I tried to use pyinstaler and cx_Freeze but it didn't worked. It creates properly an exe file but It doesn't work. When I try to run executable It pops out empty cmd window and disapears without any error.
Im working on python 3.7.4.
There is code that I used to create exe with cx Freeze:
import cx_Freeze
executables = [cx_Freeze.Executable("GenshinHelper.py")]
cx_Freeze.setup(
name="GenshinHelper",
options={"build_exe": {"packages":["pygame",'datetime'],
"include_files":['img1.jpg','img2.jpg']}},
executables = executables
)
Here is one way t do that;
first install pyinstaller;
pip install pyinstaller
then write this command;
pyinstaller --onefile -w your_file.py
--onefile will convert all the files in your project into a single file.
-w: command prompt (console) will not pop-up when you will run this .exe file. If your app is a console app, then remove -w.
This will convert your file into an .exe file and will run on any other computer without python installed.
More info at https://youtu.be/UZX5kH72Yx4.

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: Can't find .so module when exe is executed

A python script uses a .so file.
I made an exe for this python script using PyInstaller.
But when I execute the generated exe, it is unable to locate this .so file
So how to link this .so to a python code that will get converted to a .exe
Note: when running the .py program, if I set the location of .so in LD_LIBRARY_PATH, it executes the program correctly but once I make the exe using
pyinstaller script.py --onefile
(with .so in the same directory), it doesnt find the .so file..
Thank you in advance
You need to make sure that your . so file is in your system library path as well as your python library path. Setting your LD path is a quick fix. PyInstaller will need it in your system path. Depending on your Windows version it's Environment variables>PATH.

Categories