Create Executable For Windows From Python Codebase That Needs Poppler
I am using pdf2image in my code that in turn needs PATH to have the /bin folder of the Poppler binaries. I will need this in the PATH even after I create an executable that can run
Solution 1:
Try pyinstaller --add-binary 'path\to\poppelr' script_name.py
The --add-binary
flag points pyinstaller
to the binary location so it can include it.
edit 2
Use the os
module to add to SYSTEM PATH
.
I am using Jitsi.exe
as a proof of concept. This is a program I have that is not on system path. replace it with the path to the program you want to run.
import os
# The os.eviron method returns a dict object of the users PATH
path = os.environ['PATH']
path = path + ';C:\Program Files\Jitsi'# Append the path to bin as a string
os.environ['PATH'] = path # Override value of 'PATH' key in the dictprint(os.environ['PATH']) # This is the new updated PATH
os.system('Jitsi') # Using system shell to call a program that was not on my PATH and now is
Note: This updates the path for the current process only. Once the python process ends the PATH is returned to it's previous state.
Tested on a windows system
Post a Comment for "Create Executable For Windows From Python Codebase That Needs Poppler"