django-extensions 在 Django1.8 上对我很有效,但我已经在 Ubuntu 16.04 上使用 Django1.9、Python 3.5 开始了一个新项目,并尝试生成模型图,但出现以下错误:
- 安装 django-extensions1.6 后,我运行命令生成模型图:
python manage.py graph_models -a -g -o myapp_models.png
我收到此错误:
CommandError: Neither pygraphviz nor pydot could be found to generate the image
当我安装 pygraphviz 时,我收到此错误:
Traceback (most recent call last): File "./manage.py", line 10, in <module> execute_from_command_line(sys.argv) File "/home/shaifali/.virtualenvs/drf-auth/lib/python3.5/site-packages/django/core/management/__init__.py", line 353, in execute_from_command_line utility.execute() File "/home/shaifali/.virtualenvs/drf-auth/lib/python3.5/site-packages/django/core/management/__init__.py", line 345, in execute self.fetch_command(subcommand).run_from_argv(self.argv) File "/home/shaifali/.virtualenvs/drf-auth/lib/python3.5/site-packages/django/core/management/base.py", line 348, in run_from_argv self.execute(*args, **cmd_options) File "/home/shaifali/.virtualenvs/drf-auth/lib/python3.5/site-packages/django/core/management/base.py", line 399, in execute output = self.handle(*args, **options) File "/home/shaifali/.virtualenvs/drf-auth/lib/python3.5/site-packages/django_extensions/management/utils.py", line 57, in inner ret = func(self, *args, **kwargs) File "/home/shaifali/.virtualenvs/drf-auth/lib/python3.5/site-packages/django_extensions/management/commands/graph_models.py", line 89, in handle self.render_output_pydot(dotdata, **options) File "/home/shaifali/.virtualenvs/drf-auth/lib/python3.5/site-packages/django_extensions/management/commands/graph_models.py", line 152, in render_output_pydot graph.write(output_file, format=format) AttributeError: 'list' object has no attribute 'write'
如前所述django-extensions docs,当我尝试安装 pyparsing==1.5.7 时,出现以下错误:
Collecting pyparsing==1.5.7 Using cached pyparsing-1.5.7.zip Complete output from command python setup.py egg_info: Traceback (most recent call last): File "<string>", line 1, in <module> File "/tmp/pip-build-1_hzke3p/pyparsing/setup.py", line 9, in <module> from pyparsing import __version__ as pyparsing_version File "/tmp/pip-build-1_hzke3p/pyparsing/pyparsing.py", line 855 except ParseBaseException, err: ^ SyntaxError: invalid syntax ---------------------------------------- Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-1_hzke3p/pyparsing/
我安装了没有任何版本的 pyparsing 和 pydot,我得到了与只有 pygraphviz 相同的错误:
AttributeError: 'list' object has no attribute 'write'
- 我也尝试过安装 pydotplus,如另一个stackover 类似问题中所述,但没有任何改变。