【问题标题】:django extensions OSError: [Errno 2] "dot.exe" not found in pathdjango 扩展 OSError: [Errno 2] "dot.exe" not found in path
【发布时间】:2018-05-17 09:09:15
【问题描述】:

我正在尝试安装 django-extensions 以在我的 Django 休息项目 中可视化我的模型。完整的堆栈跟踪:

(vb_env_drf) D:\Development\Bern\VB_rewrite\VB_DRF_Backend>pip install django-extensions
Collecting django-extensions
  Using cached https://files.pythonhosted.org/packages/d4/b5/f141b351b49db2cb4c855cd8adbdb98cc49f3944a924ddfe51790bb46402/django_extensions-2.0.7-py2.py3-none-any.whl
Requirement already satisfied: six>=1.2 in d:\development\bern\vb_rewrite\vb_env_drf\lib\site-packages (from django-extensions) (1.11.0)
Requirement already satisfied: typing; python_version < "3.5" in d:\development\bern\vb_rewrite\vb_env_drf\lib\site-packages (from django-extensions) (3.6.4)
Installing collected packages: django-extensions
Successfully installed django-extensions-2.0.7
You are using pip version 10.0.0, however version 10.0.1 is available.
You should consider upgrading via the 'python -m pip install --upgrade pip' command.

(vb_env_drf) D:\Development\Bern\VB_rewrite\VB_DRF_Backend>python manage.py graph_models -a -o myapp_models.png
CommandError: Neither pygraphviz nor pydotplus could be found to generate the image

(vb_env_drf) D:\Development\Bern\VB_rewrite\VB_DRF_Backend>pip install pyparsing
Collecting pyparsing
  Using cached https://files.pythonhosted.org/packages/6a/8a/718fd7d3458f9fab8e67186b00abdd345b639976bc7fb3ae722e1b026a50/pyparsing-2.2.0-py2.py3-none-any.whl
Installing collected packages: pyparsing
Successfully installed pyparsing-2.2.0
You are using pip version 10.0.0, however version 10.0.1 is available.
You should consider upgrading via the 'python -m pip install --upgrade pip' command.

(vb_env_drf) D:\Development\Bern\VB_rewrite\VB_DRF_Backend>pip install pydot
Collecting pydot
Requirement already satisfied: pyparsing>=2.1.4 in d:\development\bern\vb_rewrite\vb_env_drf\lib\site-packages (from pydot) (2.2.0)
Installing collected packages: pydot
Successfully installed pydot-1.2.4
You are using pip version 10.0.0, however version 10.0.1 is available.
You should consider upgrading via the 'python -m pip install --upgrade pip' command.

(vb_env_drf) D:\Development\Bern\VB_rewrite\VB_DRF_Backend>python manage.py graph_models -a -o myapp_models.png
Traceback (most recent call last):
  File "manage.py", line 22, in <module>
    execute_from_command_line(sys.argv)
  File "D:\Development\Bern\VB_rewrite\vb_env_drf\lib\site-packages\django\core\management\__init__.py", line 364, in execute_from_command_line
    utility.execute()
  File "D:\Development\Bern\VB_rewrite\vb_env_drf\lib\site-packages\django\core\management\__init__.py", line 356, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "D:\Development\Bern\VB_rewrite\vb_env_drf\lib\site-packages\django\core\management\base.py", line 283, in run_from_argv
    self.execute(*args, **cmd_options)
  File "D:\Development\Bern\VB_rewrite\vb_env_drf\lib\site-packages\django\core\management\base.py", line 330, in execute
    output = self.handle(*args, **options)
  File "D:\Development\Bern\VB_rewrite\vb_env_drf\lib\site-packages\django_extensions\management\utils.py", line 59, in inner
    ret = func(self, *args, **kwargs)
  File "D:\Development\Bern\VB_rewrite\vb_env_drf\lib\site-packages\django_extensions\management\commands\graph_models.py", line 168, in handle
    self.render_output_pydot(dotdata, **options)
  File "D:\Development\Bern\VB_rewrite\vb_env_drf\lib\site-packages\django_extensions\management\commands\graph_models.py", line 230, in render_output_pydot
    graph.write(output_file, format=format)
  File "D:\Development\Bern\VB_rewrite\vb_env_drf\lib\site-packages\pydot.py", line 1756, in write
    s = self.create(prog, format, encoding=encoding)
  File "D:\Development\Bern\VB_rewrite\vb_env_drf\lib\site-packages\pydot.py", line 1867, in create
    raise OSError(*args)
OSError: [Errno 2] "dot.exe" not found in path.

(vb_env_drf) D:\Development\Bern\VB_rewrite\VB_DRF_Backend>

我还在我的设置中添加了django_extensions

GRAPH_MODELS = {
  'all_applications': True,
  'group_models': True,
} 

我的 requirements.ts 如下所示:

Django==1.11.12
djangorestframework==3.8.2
django-cors-headers==2.2.0
drfdocs==0.0.11
mysql-python==1.2.5
django-rest-auth==0.9.3
django-allauth==0.35.0
nltk==3.2.5
django-extensions==2.0.7
pyparsing==2.2.0
pydot==1.2.4

我使用的是 Windows 10。如何解决此错误?我需要在我的 Windows 路径中添加任何内容吗?或者对于 Django 休息,我需要其他库 (https://github.com/chibisov/drf-extensions)

【问题讨论】:

    标签: django django-rest-framework django-extensions


    【解决方案1】:

    dot.exe 是一个graphviz 可执行文件,在搜索路径中找不到。

    您是否安装了 graphviz 及其依赖项?

    如果是,它们是否在windows的搜索路径中?

    【讨论】:

    • 谢谢!我完全错过了。
    猜你喜欢
    • 2019-01-29
    • 1970-01-01
    • 2017-02-10
    • 2018-02-03
    • 2015-01-11
    • 2010-10-28
    • 2015-12-30
    • 2014-06-23
    • 1970-01-01
    相关资源
    最近更新 更多