Problems after generating the exe from a py file - python-3.x

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

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

Getting error when using pynput with pyinstaller

A friend of mine asked me to write him a program, and I used pynput to handle some of the inputs and other features. When I convert the program an executable with pyinstaller, launcing the executable gives me this error: File "site-packages\pynput\keyboard\__init__.py", line 31, in <module> File "site-packages\pynput\_util\__init__.py", line 82, in backend ImportError [11492] Failed to execute script friend_project
I have tried using the pyinstaller command pyinstaller --onefile friend_project.py, and also using auto-py-to-exe to run it.
Using pyinstaller with other modules like pygame or pyopengl gives me no error, but this one module does.
Running the script by it self with the python inturpeter works fine, but I would perfer to have it be an exe so I can give it to him with out him needing python to run it.
Please fall back to 1.6.8 version of pynput.
pip install pynput==1.6.8
If you are running Windows you need to add these parameters to the command line (for the first time, after that they will be included in the generated spec file).
--hidden-import "pynput.keyboard._win32" --hidden-import "pynput.mouse._win32"
For Linux, use:
--hidden-import "pynput.keyboard._xorg" --hidden-import "pynput.mouse._xorg"
More information can be found in this Github issue.

how to install python library (Imported in our script file) automatically in windows 7

I have a script file named updatesCode.py
inside this file i am importing openpyxl,
i downloaded the tar file and extracted , went to setup.py file directory and ran python setup.py install because pip was not working in my case.
my question is : if i give my updatedCode.py to some one else, it will give error related to installation of the opepyxl library
Is there any way(like a script file that installs library) to insatll openpyxl library automatically before running updatedCode.py.
i tried to write a setup.py file but it didnt work. please give me suggestions to achieve this (how to specify dependencies in setup.py file )
updatedCode.py file has simple code to access a excel sheet, I am not creating a package.

How do I make PyInstaller bundle Tcl/Tk for OSX targets? - Import Error Tcl/Tk modules not found - Pyinstaller on Mac is not working

I have a frustrating problem that set me back a day trying to get an executable file from my finished bookstore app.
I used the Pyinstaller --onefile --windowed bookstore.py from the main project menu, also vm/bin/Pyinstaller --onefile --windowed bookstore.py which created the .exe and .app file successfully.
HOWEVER, when running the .app file, nothing happens. It starts, and just disappears.
I ran the core executable from the cli on Mac from the main project folder with open dist/bookstore.app/Contents/Macos/bookstore and, loads of research and over 20 variations of code and file changes later, I got the same same trackback (N.B. different file path for global Pyinstaller) error message back from the console.
Traceback (most recent call last):
File "bookstore.py", line 5, in <module>
File "/Users/jmulhall/Documents/Documents/Python_Project_Folder/Python3_Training/ProjectBookstore/vm/lib/python3.6/site-packages/PyInstaller/loader/pyimod03_importers.py", line 631, in exec_module
exec(bytecode, module.__dict__)
File "tkinter/__init__.py", line 36, in <module>
File "/Users/jmulhall/Documents/Documents/Python_Project_Folder/Python3_Training/ProjectBookstore/vm/lib/python3.6/site-packages/PyInstaller/loader/pyimod03_importers.py", line 714, in load_module
module = loader.load_module(fullname)
ImportError: dlopen(/var/folders/0d/6l_1mgwn4cxbrx21_nm7l8gh0000gn/T/_MEIHyYK9G/_tkinter.so, 2): Library not loaded: #loader_path/Tcl
Referenced from: /var/folders/0d/6l_1mgwn4cxbrx21_nm7l8gh0000gn/T/_MEIHyYK9G/_tkinter.so
Reason: image not found
[3899] Failed to execute script bookstore
My Mac details are as follows:
MacOs High Sierra V 10.13.3 with a standard HD on a mid 2012 Macbook Pro
My Software versions are python 3.6.4, pyinstaller 3.3.1 , virtualenv 15.1.0, sqllite3 3.19.3
The most promsing fix on github did not work ergo my query on fixing the Pyinstaller issue for mac where it loads the tcl and tk resources. The links I followed are here:​
Main Query Link - Github​,
Support File Changes Demo for hooks​
I created a pyinstaller-hooks folder and inserted the hook and pyruntime hooks file into the folder with the tclResources and tkResources name changes in the files as follows:
This did not work.
And I am still getting the above stack trace despite running the new command, picking up the new pyinstaller-hooks folder files in the main project folder, as follows:
pyinstaller --onefile --windowed --additional-hooks-dir pyinstaller-
hooks --runtime-hook pyinstaller-hooks/pyi_rth__tkinter.py bookstore.py
Why is it still not finding the the new files with Tree() and os.path.join()) functions altered to tkResources/tclResources and thus crashing the app when it tries to launch. I could not test the .exe as I have only a Mac environment so Im only focused on the .app right now. Can anybody help with this?
Nearly forgot, my main project folder view is as follows:

Resources