django-extensions生成模型图

时间:2016-11-11 17:43:14

标签: django python-3.5 pygraphviz django-extensions

使用Django1.8,django-extensions对我来说效果很好,但是我已经在Ubuntu 16.04上用Django1.9,Python 3.5开始了一个新项目并尝试生成模型图但是出现以下错误:

  1. 安装django-extensions1.6后,我运行命令生成模型图:
  2. python manage.py graph_models -a -g -o myapp_models.png

    我收到此错误:

    CommandError: Neither pygraphviz nor pydot could be found to generate the image

    1. 当我安装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'

    2. 如上所述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/
      
    3. 我已经安装了没有任何版本的pyparsing和pydot,我得到了与pygraphviz相同的错误:

    4. AttributeError: 'list' object has no attribute 'write'

      1. 我也尝试过安装另一个stackover similar question中提到的pydotplus,但没有任何改变。

0 个答案:

没有答案