`dot2tex` 需要 root 权限才能工作?

`dot2tex` 需要 root 权限才能工作?

我在尝试使用 dot2tex 环境编译某些 LaTeX 时遇到问题:我收到一条错误消息

Opening dot2tex stream test-dot2tex-fig1.dotTraceback (most recent call last):
  File "~/.local/bin/dot2tex", line 7, in <module>
    from dot2tex.dot2tex import main
  File "~/.local/lib/python3.6/site-packages/dot2tex/__init__.py", line 36, in <module>
    __version__ = d2t.__version__
AttributeError: module 'dot2tex' has no attribute '__version__'

尝试编译时pdflatex --shell-escape file.tex:生成的 pdf 中没有该图。
但是,如果我sudo在此之前添加,该命令就会起作用,并正确生成 pdf。

有人知道我该如何解决这个问题吗?

以下是产生错误的最小代码:

\documentclass[a4paper,12pt]{article}
\usepackage{graphicx}
\usepackage[a4paper]{geometry}
\usepackage{dot2texi}
\usepackage{tikz}
\usetikzlibrary{shapes,arrows}

\begin{document}

\begin{dot2tex}[dot,mathmode,scale = 0.5]
digraph G {
node [shape="circle"];
a [label = "a"];
b [label = "b"];
b -> a ;
}
\end{dot2tex}

\end{document}

答案1

dot2tex对于 python 3 来说似乎有问题。您必须改用 python 2:

  • 卸载dot2texPython 3:$ pip3 uninstall dot2tex
  • dot2tex为 Python 2安装:$ pip2 install dot2tex

相关内容