PyInstaller: EXE opens and closes - python-3.x

As you can read in the headline, my .exe file doesn't do his job. After converting the .py file to an .exe file using PyInstaller, the file opens and closes a second later.
To create an .exe file I use:
pyinstaller --onefile --icon="pong.ico" pong.py
Any other files work fine. I use Python 3.8 and PyInstaller 3.6.
Thanks for answers.

Related

how to Run .py file

I have written a "random movie suggester" code that will basically read the files of the directory where the .py file is stored and randomly pick one of them and print it out.
My problem is -
How to make .py file simple to run for non-technical person?
(e.g. I tried .bat but i had to hard code the path of the file).
Other solutions ask to install IDEs and run it.
First you have to install python on your computer.
Then you can type in your terminal:
python [the file name or the path to access it]
But I don't think this is what you are looking for...
You can create a .exe file with your python program using the pyinstaller module then running this in your terminal.
pip pyinstaller
pyinstaller --onefile [the name of the file]
The first line installs the module using pip.
The second line will create a .exe file that does exactly the same as your python code.

How can I decompile an exe file I made with Pyinstaller?

I made a .py file and was looking how to convert it into an .exe file. I found pyinstaller and while messing around with it I was able to create a basic exe file with pyinstaller. The problem is that I didnt have a copy of my .py file as backup because I'm a beginner and now I can't look at my source code. Is there a way for me to decompile the pyinstaller files to attempt to recover some of my code?
My .py file was created in python 3.8 if that is relevant

Problems after generating the exe from a py file

I am using Python Version 3.7.3 and PyInstaller 3.5. I have written a Python script named read.py which will read the scanned PDF and convert it to a text file. I could successfully generate the exe using the PyInstaller commands pyi-makespec --onefile read.py and pyinstaller --onefile read.spec. The .exe file is working fine in my system where i have all the packages installed, but when I tried to run it on a different Windows PC where the Python packages are not available, it is looking for the poppler module.
I even tried to add the hook file for poppler in pyinstaller hooks folder but it did not take this hook file while generating the .exe file.
Please help to resolve this issue, or please let me know if there is any other way to generate the exe without having the dependencies on the Python supporting files.
Below is the error which I'm getting when I execute the .exe file on a different PC:
File "read_image.py", line 29, in <module>
File "site-packages\pdf2image\pdf2image.py", line 54, in convert_from_path
File "site-packages\pdf2image\pdf2image.py", line 244, in _page_count pdf2image.exceptions.PDFInfoNotInstalledError: Unable to get page count. Is poppler installed and in PATH? [17920] Failed to execute script read_image
Thanks for the Help...

python main.py turn to text file in pycharm

I suddenly have a problem with file main.py .
I am using pycharm with python version 3.6 from anaconda.
I had a full project that run fine and now the 'main.py' became text file.
If I open a new project and name a new python file as 'main' it automatically turn into text file (any other name remains .py file).
What is the problem?

Exe to python with pyinstaller?

So I made a huge mistake and deleted my code file (python). The only thing I have is my python file as .exe that I created with pyinstaller. Is there a way to reverse this and to extract my code file from .exe?
You can extract the contents of the .exe file using PyInstaller Extractor. Run it like this:
python pyinstxtractor.py executable.exe
You will then get a bunch of files, including your original python file.

Resources