How can I decompile an exe file I made with Pyinstaller? - python-3.x

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

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.

PyInstaller: EXE opens and closes

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.

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...

Error when Converting .py to .exe with cx_freeze

I am trying to convert my .py code to .exe. I tried all the options from posts on here and on the web, and all I could up with was the error below when I used cx_Freeze, and the .exe not opening when I used pyinstaller.
can someone help with the error below or give an alternative that works?
PS: my py code is actually ipython code from my jupyter notebook, but I'm trying not to share the code source.
Finally got it working while using pyinstaller, the key was to open the .exe file from the command window to be able to see the warning, which was "Import cv2 not found" after I deleted that line(since I was not using that module) and re built it, the .exe file now works. Hope this will help someone one day

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