我正在使用django-extensions为我的 Django 应用程序生成模型图。
我的安装步骤如下:
$ pip install django-extensions
$ pip install pyparsing pydot
由于缺少 C 扩展,pygraphviz
安装失败(如上所述):
$ pip install pygraphviz # this does not work
现在,使用 graph_models
中的 pydot
选项documentation适用于 .dot
文件:
$ python manage.py graph_models -a -I Device,Vehicle -o my_project_subsystem.dot
但是创建 PNG 文件会中断并指示 dot
不在 PATH
上:
$ python manage.py graph_models --pydot -a -g -o my_project_visualized.png
有错误:
FileNotFoundError: [WinError 2] "dot" not found in path
this 中提供了使用 conda
和 pygraphviz
解决此问题的方法。回答。
但是如何仅使用 pip
而不使用 anaconda
创建图表呢?
对我来说,使用 pydot 或 pygraphviz 并不重要。我只想将模型创建为 PNG 文件。
提前致谢!
最佳答案
花了一段时间,但我使用以下步骤使其正常工作:
- 通过
$ pip install django-extensions==3.1.5
安装 django 扩展 - 通过
$ pip install pydotplus==2.0.2安装pydotplus
- 通过 installer 安装 GraphViz并手动将其添加到用户
PATH
在settings.py
中包含django_extensions
:
INSTALLED_APPS = (
...
'django_extensions',
...
)
运行命令:
$ python manage.py graph_models -a -o myapp_models.png
关于python - 使用 Windows 10 使用 django-extensions 生成 PNG 格式的模型图(不使用 Conda 或 Anaconda),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/71144974/