使用子进程调用不返回这样的文件或目录

2024-09-30 22:24:44 发布

您现在位置:Python中文网/ 问答频道 /正文

我过去成功地使用过这个

from subprocess import call

import os

为了确保打印路径正确,我在打印后查看了控制台

print str(os.path.abspath(str(os.path.join(settings.MEDIA_ROOT, 'user_2/SampleIllustration.pdf'))))])

这个路径/目录肯定存在;但是,在尝试将pdf转换为文本文件后

call(["pdftotext", "-layout", str(os.path.abspath(str(os.path.join(settings.MEDIA_ROOT, 'user_2/SampleIllustration.pdf'))))])

我收到一个错误

No such file or directory

奇怪的是,当我在本地机器上开发时,这个call按预期工作。只有当我在服务器上时,我才会收到此消息

编辑:

完整的错误消息是:

OSError: [Errno 2] No such file or directory

Tags: pathimport路径settingspdfos错误root