我在我的代码中使用pdf2image,这反过来又需要PATH才能获得Poppler二进制文件的/bin
文件夹。即使创建了可以在Windows上运行的可执行文件,我也需要在PATH中使用它。 Pyinstaller很棒,但是does not support poppler还没有。我该如何包装呢?
答案 0 :(得分:1)
尝试pyinstaller --add-binary 'path\to\poppelr' script_name.py
--add-binary
标志将pyinstaller
指向二进制位置,以便可以包含它。
修改2
使用os
模块添加到SYSTEM PATH
。
我正在使用Jitsi.exe
作为概念证明。这是我没有在系统路径上的程序。将其替换为要运行的程序的路径。
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
注意: 这将仅更新当前过程的路径 。 python进程结束后,PATH返回其先前状态。
在Windows系统上测试