djangodjango-rest-frameworkdjango-extensions

django extensions OSError: [Errno 2] "dot.exe" not found in path


I am trying to install django-extensions to visualize my models in my Django rest project. Complete stacktrace:

(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>

I have added django_extensions in my settings also,

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

My requirements.ts looks like following:

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

I am on Windows 10. How do I resolve this error? Do I need to add anything in my Windows path?Or for Django rest I need other library (https://github.com/chibisov/drf-extensions)


Solution

  • dot.exe is a graphviz executable, which is not found in the search paths.

    Have you installed graphviz and its dependencies?

    If yes, are they in the search path of windows?