我正在使用以下库和代码探索树图:
from dsplot.graph import Graph
graph = Graph(
{0: [1, 4, 5], 1: [3, 4], 2: [1], 3: [2, 4], 4: [], 5: []}, directed=True
)
graph.plot()
当我运行代码时,出现以下错误:
from dsplot.graph import Graph
ModuleNotFoundError: No module named 'dsplot'
我尝试在 PyCharm 终端上使用以下命令 pip 安装
dsplot
库:
pip install dsplot
但这会导致另一个错误:
Collecting dsplot
Using cached dsplot-0.9.0-py3-none-any.whl (8.8 kB)
Collecting pygraphviz<2.0,>=1.7
Using cached pygraphviz-1.12.tar.gz (104 kB)
ERROR: Error [WinError 3] The system cannot find the path specified while executing command pip subprocess to install build dependencies
Installing build dependencies ... error
ERROR: Could not install packages due to an OSError: [WinError 3] The system cannot find the path specified
安装库时出现此问题的原因是什么以及如何解决?
看起来你还没有安装
pygraphviz
。
安装
pygraphviz
尝试从他们的官方网站下载它,并通过单击“将 Graphviz 添加到当前用户的系统路径”确保将其添加到您的路径中。在您的终端中,运行
dot -V
,如果它输出您的 pygraphviz
版本,则您应该已准备好运行 pip install dsplot
。
如果
dot -V
未返回版本:
确保在安装过程中选中此框:
如果您选中了该框,但它仍然不在您的路径中:
将
Graphviz
添加到您的路径后,打开终端并再次尝试 dot -V
。如果返回版本,那么您应该能够运行 pip install dsplot
。