在Pycharm中导入dsplot库时出现问题

问题描述 投票:0回答:1

我正在使用以下库和代码探索树图:

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

安装库时出现此问题的原因是什么以及如何解决?

windows pycharm
1个回答
0
投票

看起来你还没有安装

pygraphviz

安装

pygraphviz

尝试从他们的官方网站下载它,并通过单击“将 Graphviz 添加到当前用户的系统路径”确保将其添加到您的路径中。在您的终端中,运行

dot -V
,如果它输出您的
pygraphviz
版本,则您应该已准备好运行
pip install dsplot

如果

dot -V
未返回版本:

确保在安装过程中选中此框:

如果您选中了该框,但它仍然不在您的路径中:

  1. 找到Graphviz的安装位置;它可能位于“C:\Program Files\Graphviz”中,但取决于安装和操作系统。点击这个目录,右键“bin”复制路径。
  2. 打开“开始搜索”,输入“env”,然后选择“编辑系统环境变量”。
  3. 点击系统属性中的“环境变量”
  4. 在“系统变量”下找到“路径变量”并选择“编辑”
  5. 点击“新建”
  6. 粘贴到 Graphviz 的路径中,可能是 C:\Program Files\Graphviz 中
  7. 在所有打开的窗口上单击“确定”以应用更改

Graphviz
添加到您的路径后,打开终端并再次尝试
dot -V
。如果返回版本,那么您应该能够运行
pip install dsplot

© www.soinside.com 2019 - 2024. All rights reserved.