巨蟒+巨蟒。TypeError:打印不可用 [英] python+igrph. TypeError: plotting not available

查看:0
本文介绍了巨蟒+巨蟒。TypeError:打印不可用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想用python笔记本,iggraph包来画画,示例代码在这里(我觉得是对的)

!pip install cairocffi
import cairocffi as cairo

corlor = []
for i in g.vs['name']:
    if set([i]) < set(degree_15):
        corlor.append('red')
    elif set([i]) < set(degree_30):
        corlor.append('rgba(255,0,0,0.5)')
    elif set([i]) < set(degree_60):
        corlor.append('orange')
    else:
        corlor.append('yellow')
ig.plot(g,
        #'C:UsersVincent DuDesktopdegree_plot.jpg',
        layout=geometry_layout,
        vertex_label=g.vs['name'],
        scale=1.0,
        vertex_color=corlor,
        vertex_frame_width=0.5,
        edge_width=0.05,
        vertex_label_size=ig.rescale(g.degree(),out_range=(1,12)),
        vertex_size=ig.rescale(g.degree(),out_range=(5,25)),
        bbox=(1200,800),
        margin = 10,
       )

仍然有一个错误。我不知道如何解决这个问题,谢谢!

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-120-73eb4de82dd4> in <module>()
     21         vertex_size=ig.rescale(g.degree(),out_range=(5,25)),
     22         bbox=(1200,800),
---> 23         margin = 10,
     24        )

//anaconda/lib/python3.5/site-packages/igraph/drawing/__init__.py in plot(obj, target, bbox, *args, **kwds)
    444         bbox = BoundingBox(bbox)
    445 
--> 446     result = Plot(target, bbox, background=kwds.get("background", "white"))
    447 
    448     if "margin" in kwds:

//anaconda/lib/python3.5/site-packages/igraph/drawing/__init__.py in __init__(self, target, bbox, palette, background)
    115         """
    116         self._filename = None
--> 117         self._surface_was_created = not isinstance(target, cairo.Surface)
    118         self._need_tmpfile = False
    119 

//anaconda/lib/python3.5/site-packages/igraph/drawing/utils.py in __getattr__(self, _)
    394 
    395     def __getattr__(self, _):
--> 396         raise TypeError("plotting not available")
    397     def __call__(self, _):
    398         raise TypeError("plotting not available")

TypeError: plotting not available

我想我已经安装了开罗,但它仍然不能工作

推荐答案

Python3.7 venv:

(/home/victoria/venv/py37)$ python

  Python 3.7.3 (default, Mar 26 2019, 21:43:19) 
  [GCC 8.2.1 20181127] on linux
  Type "help", "copyright", "credits" or "license" for more information.

  >>> from igraph import *
  >>> g = Graph.Famous("petersen")
  >>> plot(g)
  Traceback (most recent call last):
    File "<stdin>", line 1, in <module>
    ...
  TypeError: plotting not available
(/home/victoria/venv/py37)$ pip install cairocffi
  ...
  Successfully installed cairocffi-1.0.2 cffi-1.12.3 pycparser-2.19

现在打印(忽略警告):

(/home/victoria/venv/py37)$ python

  Python 3.7.3 (default, Mar 26 2019, 21:43:19) 
  [GCC 8.2.1 20181127] on linux
  Type "help", "copyright", "credits" or "license" for more information.
  >>> from igraph import *
  >>> g = Graph.Famous("petersen")
  >>> plot(g)

  (gthumb:31636): Gtk-WARNING **: 14:43:58.342: Failed to register client: GDBus.Error:org.freedesktop.DBus.Error.UnknownMethod: Method "RegisterClient" with signature "ss" on interface "org.xfce.Session.Manager" doesn't exist
  <igraph.drawing.Plot object at 0x7f1810e36e80>

  >>>

结果:

这篇关于巨蟒+巨蟒。TypeError:打印不可用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆