python - 如何从 Python 将 "dot"作为命令运行?

标签 python macos path graphviz dot

我在 Mac OSX Leopard 上使用 Python。

我正在尝试从 Python 运行程序“dot”(Graphviz 的一部分):

# -*- coding: utf-8 -*-
import os

print os.environ['PATH']
print os.system("ls >> a.txt")
print os.system("dot -o9.png -Tpng ./6.dot")

命令“ls”只是为了确保 python 在正确的目录中。这是。我得到的结果是:

/usr/bin:/bin:/usr/sbin:/sbin 0 32512

我的理解是 32512 错误意味着 python 找不到文件,因为文件 6.dot 在那里(如果我从我收到的终端运行“dot -o9.png -Tpng ./6.dot”没有错误,并且生成了 9.png),我假设 Python 找不到点文件。

我可能需要将点文件添加到路径中。但我不知道它在哪里。如果我运行:

whereis dot

我没有收到任何答复。

如何找到点可执行文件?
或者,我可以从 Python 内部将点程序作为命令运行吗?

最佳答案

whereis 定位手册页,which 定位二进制文​​件。所以试试哪个点

关于python - 如何从 Python 将 "dot"作为命令运行?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/955504/

相关文章:

python - 使用 nginx、uwsgi、flask 轻松进行应用程序日志记录/调试?

python - 创建或更新Python字典条目

git - 显示 4 个 Pane 的 Mac 的 3 向 merge 工具

swift - 命令行工具中的 URLSession : control multiple tasks and convert HTML to text

python - 在 Python 中确保可靠路径的最佳方法是什么?

python - XX 处的 Django 序列化程序 ManyRelatedManager 对象不是 JSON 可序列化的

python - 运行时错误: There is no current event loop in thread 'MainThread'

macos - 如何绑定(bind)到 NSTableColumn 的 headerTitle?

linux - 有没有合理的方法将新路径附加到 bashrc 中的 PATH?

grails - 在 Grails 插件中访问资源