I am trying do convert XSL-FO to PDF following this tutorial, but to do that I need to run a command that uses an environment variable called FOP_CMD:
我正在尝试按照本教程将XSL-FO转换为PDF,但要做到这一点,我需要运行一个使用名为FOP_CMD的环境变量的命令:
doc = Document(tfactory('/home/username/Downloads/file.fo'))
doc.generate(params, oformat='pdf')
I saved the environment variable in the file ~/etc/environment
and if I run echo $FOP_CMD
in the terminal it gives me the right path: /home/username/fop-1.1
.
我将环境变量保存在文件〜/ etc / environment中,如果我在终端中运行echo $ FOP_CMD,它给出了正确的路径:/home/username/fop-1.1。
However, when running the application, the compiler tells me the following: Exception: Unable to find the path to execute FOP.Check the environment variable "FOP_CMD"
但是,在运行应用程序时,编译器会告诉我以下内容:异常:无法找到执行FOP的路径。检查环境变量“FOP_CMD”
The weird thing is that in Windows I am able to run the command without any problems and the envirnment variable points to the same path but in Ubuntu this erros shows up.
奇怪的是,在Windows中,我能够毫无问题地运行命令,并且环境变量指向相同的路径,但在Ubuntu中,这个错误显示出来。
I also tried to change the path to /home/username/fop-1.1/fop
(following the advice given in this post) but it keeps giving the same error.
我还尝试将路径更改为/home/username/fop-1.1/fop(遵循本文中给出的建议),但它一直给出相同的错误。
Does anyone know what can I be doing wrong?
有谁知道我能做错什么?
1 个解决方案
#1
Try setting the environment variable inside your Python program like so:
尝试在Python程序中设置环境变量,如下所示:
import os
if not 'FOP_CMD' in os.environ:
os.environ['FOP_CMD'] = '/home/username/fop-1.1'
#1
Try setting the environment variable inside your Python program like so:
尝试在Python程序中设置环境变量,如下所示:
import os
if not 'FOP_CMD' in os.environ:
os.environ['FOP_CMD'] = '/home/username/fop-1.1'