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 on Windows. Pyinstaller is great but does not support poppler yet. How do I go about packaging this?
1 Answer
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 dict
print(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
2 Comments
user2775878
Thank you, but will
--add-binary update the system PATH?medic17
@user2775878 I changed my answer as the old one didn't update system PATH. Please see if this helps you and update me